Commit 619f5845 authored by 任建锋's avatar 任建锋

rjf

parent 4903f830
export class YtSceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas;
public engine;
private static instance: YtSceneManager;
public static get ins(): YtSceneManager {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
}
constructor(){
this.init()
}
public init(){
var container = document.getElementById("annieEngine");
var w = document.documentElement.clientWidth || document.body.clientWidth;
var h = document.documentElement.clientHeight || document.body.clientHeight;
document.getElementById("_a2x_canvas").style.position = "absolute";
document.getElementById("_a2x_canvas").setAttribute("touch-action","none");
var webglCanvas = document.createElement("canvas");
webglCanvas.width = w;
webglCanvas.height = h;
container.appendChild(webglCanvas);
this.engine=new BABYLON.Engine(webglCanvas, true);
this.scene = this.createSceneBefore(webglCanvas);
var _canvas:any=document.getElementById("_a2x_canvas")
this.engine.getRenderingCanvas=()=>{
return _canvas;
};
this.engine.runRenderLoop(()=>{
this.scene.render();
TWEEN.update();
});
window.addEventListener("resize", ()=> {
this.engine.resize();
});
}
public createSceneBefore(webglCanvas){
var scene = new BABYLON.Scene(this.engine);
var n = scene._onPointerUp
, o = scene._onPointerDown
, r = scene._onPointerMove
, a = BABYLON.Tools.GetPointerPrefix();
webglCanvas.removeEventListener(a + "move", r),
webglCanvas.removeEventListener(a + "down", o),
window.removeEventListener(a + "up", n),
scene._onPointerUp = (e)=>{
void 0 !== e.pointerId && n(e)
}
,
scene._onPointerDown = (e)=> {
void 0 !== e.pointerId && o(e)
}
,
scene._onPointerMove = (e)=> {
void 0 !== e.pointerId && r(e)
}
,
webglCanvas.addEventListener(a + "move", scene._onPointerMove, !1),
webglCanvas.addEventListener(a + "down", scene._onPointerDown, !1),
window.addEventListener(a + "up", scene._onPointerUp, !1);
//下面的代码是为了设置微信上面的touch事件兼容
var camera = new BABYLON.FreeCamera("baseCamera", new BABYLON.Vector3(0, 0, 0), scene);
return scene;
}
/* public get stage(): any {
return this._stage;
}*/
/* public get scene(): BABYLON.Scene {
return this._scene;
}
public get canvas(): any {
return this._canvas;
}
public get engine(): any {
return this._engine;
} */
public change(display){
/* console.log(display)
var i;
for(i in display){
console.log(display[i])
}*/
/* for(var l of SceneManager.ins.scene.meshes){
l.dispose()
} */
YtSceneManager.ins.scene.meshes=[]
/*var j;
for(j in SceneManager.ins.stage){
console.log(SceneManager.ins.stage[j])
if( SceneManager.ins.stage[j]){
if(SceneManager.ins.stage[j].getChildMeshes){
SceneManager.ins.stage[j].getChildMeshes(false,(child)=>{
child.dispose();
});
}
if( SceneManager.ins.stage[j].dispose){
SceneManager.ins.stage[j].dispose()
}
}
}*/
YtSceneManager.ins.stage=display;
}
/* public change(module){
// console.log(this._stage._children)
if(this.stage._children){
this.stage._children.forEach(function (child) {
this.stage.removeChild(child)
child.dispose()
}.bind(this))
}
this.stage.addChild(module)
// console.log( this._scene)
}*/
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ var YtSceneManager = /** @class */ (function () {
webglCanvas.height = h;
container.appendChild(webglCanvas);
this.engine = new BABYLON.Engine(webglCanvas, true);
this.scene = this.createScene(webglCanvas);
this.scene = this.createSceneBefore(webglCanvas);
var _canvas = document.getElementById("_a2x_canvas");
this.engine.getRenderingCanvas = function () {
return _canvas;
......@@ -39,7 +39,7 @@ var YtSceneManager = /** @class */ (function () {
_this.engine.resize();
});
};
YtSceneManager.prototype.createScene = function (webglCanvas) {
YtSceneManager.prototype.createSceneBefore = function (webglCanvas) {
var scene = new BABYLON.Scene(this.engine);
var n = scene._onPointerUp, o = scene._onPointerDown, r = scene._onPointerMove, a = BABYLON.Tools.GetPointerPrefix();
webglCanvas.removeEventListener(a + "move", r),
......
{"version":3,"file":"YtSceneManager.js","sourceRoot":"","sources":["../../src/manager/YtSceneManager.ts"],"names":[],"mappings":";;AACA;IAgBI;QACI,IAAI,CAAC,IAAI,EAAE,CAAA;IACf,CAAC;IATD,sBAAkB,qBAAG;aAArB;YACI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,IAAI,CAAC,QAAQ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;;;;;;;;;;UAUM;IAEG,+BAAM,GAAb,UAAc,OAAO;QAClB;;;;YAII;QAEJ;;aAEK;QAEJ,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAC,EAAE,CAAA;QAElC;;;;;;;;;;;;;WAaG;QACH,cAAc,CAAC,GAAG,CAAC,KAAK,GAAC,OAAO,CAAC;IACrC,CAAC;IAaL,qBAAC;AAAD,CAAC,AApID,IAoIC;AApIY,wCAAc"}
\ No newline at end of file
......@@ -31,7 +31,7 @@ export class YtSceneManager{
webglCanvas.height = h;
container.appendChild(webglCanvas);
this.engine=new BABYLON.Engine(webglCanvas, true);
this.scene = this.createScene(webglCanvas);
this.scene = this.createSceneBefore(webglCanvas);
var _canvas:any=document.getElementById("_a2x_canvas")
this.engine.getRenderingCanvas=()=>{
return _canvas;
......@@ -45,7 +45,7 @@ export class YtSceneManager{
});
}
public createScene(webglCanvas){
public createSceneBefore(webglCanvas){
var scene = new BABYLON.Scene(this.engine);
var n = scene._onPointerUp
, o = scene._onPointerDown
......
......@@ -7,6 +7,6 @@ export declare class YtSceneManager {
static readonly ins: YtSceneManager;
constructor();
init(): void;
createScene(webglCanvas: any): BABYLON.Scene;
createSceneBefore(webglCanvas: any): BABYLON.Scene;
change(display: any): void;
}
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