Commit 0a4af8af authored by rockyl's avatar rockyl

nothing

parent 4127b833
......@@ -6,7 +6,7 @@ import HashObject from "./HashObject";
import {Component} from "./Component";
import {EngineConfig} from "../engine-config";
import {ScillaEngine} from "./ScillaEngine";
import {bubbling, traverse} from "./entity-utils";
import {bubbling, traverse} from "./utils";
/**
* 实体类
......
......@@ -10,7 +10,7 @@ import InteractContext from "./context/InteractContext";
import RenderContext, {ScaleMode} from "./context/RenderContext";
import './requestAnimationFrame';
import {AssetsManager} from "../assets-manager";
import {traverse, traversePostorder} from "./entity-utils";
import {traverse, traversePostorder} from "./utils";
import DataCenter from "../support/DataCenter";
/**
......@@ -68,8 +68,8 @@ export class ScillaEngine {
injectProp(this.customConfig, _customConfig);
injectProp(this.dataCenterConfig, _dataCenterConfig);
if(this.dataCenterConfig.dataCenterRoot){
for(let item of this.dataCenterConfig.dataCenterRoot){
if (this.dataCenterConfig.dataCenterRoot) {
for (let item of this.dataCenterConfig.dataCenterRoot) {
this._dataCenter.register(item);
}
}
......@@ -191,7 +191,7 @@ export class ScillaEngine {
return this._assetsManager;
}
get canvasElement(): HTMLCanvasElement{
get canvasElement(): HTMLCanvasElement {
return this._canvasElement;
}
......@@ -313,6 +313,15 @@ export class ScillaEngine {
})
}
/**
* 射线测试获取实体
*/
getEntitiesByRayTest(x, y) {
traversePostorder(this._root, function (child) {
return child.onInteract(2, event);
})
}
/**
* 页面坐标转画布坐标
* @param pageX
......
......@@ -8,7 +8,7 @@ import {Entity} from "../core/Entity";
import {ScillaEvent} from "../core/ScillaEvent";
import {EngineConfig} from "../engine-config";
import engine from "./ScillaEngine";
import {traverse} from "./entity-utils";
import {traverse} from "./utils";
const defMap = {};
let entityMap = {};
......
......@@ -5,6 +5,7 @@
*/
import {Entity} from "./Entity";
import {Component} from "./Component";
/**
* 节点遍历(先序遍历)
......@@ -89,3 +90,24 @@ export function bubbling(target: Entity, hitParent: (parent: Entity, ...params)
}
}
}
export function hitTest(entity: Entity){
const transform = entity.components[0];
const matrix = transform.getMatrix(true, true, true);
matrix.transformPoint(e.x, e.y, this.localPos);
let result = false;
const renderers = entity.getComponents(Renderer);
for (let renderer of renderers) {
if (renderer.hitTest(this.localPos.x, this.localPos.y)) {
if (!renderer['isUsedToMask']) {
result = true;
break
}
} else if (renderer['isUsedToMask']) {
return false
}
}
return result;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment