Commit 6832e07f authored by 任建锋's avatar 任建锋

public scene ...

parent b3b35765
{
"name": "yt",
"version": "1.0.6",
"description": "基于Babylonjs的3D框架",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
"scripts": {
},
"author": "",
"license": "ISC",
"dependencies": {
"tc": "git+ssh://git@gitlab2.dui88.com:clq/tc.git#1.0"
}
}
\ No newline at end of file
export class SceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas;
public engine;
private static instance: SceneManager;
public static get ins(): SceneManager {
if (!this.instance) {
this.instance = new SceneManager();
}
return this.instance;
}
constructor(){
this.canvas = document.querySelector("#renderCanvas");
this.engine = new BABYLON.Engine(this.canvas, true);
var createScene=function(){
{
var scene = new BABYLON.Scene(this.engine);
//下面的代码是为了设置微信上面的touch事件兼容
var n = scene._onPointerUp
, o = scene._onPointerDown
, r = scene._onPointerMove
, a = BABYLON.Tools.GetPointerPrefix();
this.canvas.removeEventListener(a + "move", r),
this.canvas.removeEventListener(a + "down", o),
window.removeEventListener(a + "up", n),
scene._onPointerUp = function(e) {
void 0 !== e.pointerId && n(e)
}
,
scene._onPointerDown = function(e) {
void 0 !== e.pointerId && o(e)
}
,
scene._onPointerMove = function(e) {
void 0 !== e.pointerId && r(e)
}
,
this.canvas.addEventListener(a + "move", scene._onPointerMove, !1),
this.canvas.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);
this.engine.setHardwareScalingLevel(0.6)
return scene;
}
}.bind(this)
this.scene = createScene();
this.engine.runRenderLoop(function () {
this.scene.render();
TWEEN.update();
}.bind(this));
window.addEventListener("resize", function() {
this.engine.resize();
}.bind(this));
}
/* 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()
} */
SceneManager.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()
}
}
}*/
SceneManager.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
...@@ -6,7 +6,7 @@ var SceneManager = /** @class */ (function () { ...@@ -6,7 +6,7 @@ var SceneManager = /** @class */ (function () {
this.engine = new BABYLON.Engine(this.canvas, true); this.engine = new BABYLON.Engine(this.canvas, true);
var createScene = function () { var createScene = function () {
{ {
var scene = new BABYLON.Scene(this._engine); var scene = new BABYLON.Scene(this.engine);
//下面的代码是为了设置微信上面的touch事件兼容 //下面的代码是为了设置微信上面的touch事件兼容
var n = scene._onPointerUp, o = scene._onPointerDown, r = scene._onPointerMove, a = BABYLON.Tools.GetPointerPrefix(); var n = scene._onPointerUp, o = scene._onPointerDown, r = scene._onPointerMove, a = BABYLON.Tools.GetPointerPrefix();
this.canvas.removeEventListener(a + "move", r), this.canvas.removeEventListener(a + "move", r),
...@@ -29,17 +29,17 @@ var SceneManager = /** @class */ (function () { ...@@ -29,17 +29,17 @@ var SceneManager = /** @class */ (function () {
window.addEventListener(a + "up", scene._onPointerUp, !1); window.addEventListener(a + "up", scene._onPointerUp, !1);
//下面的代码是为了设置微信上面的touch事件兼容 //下面的代码是为了设置微信上面的touch事件兼容
var camera = new BABYLON.FreeCamera("baseCamera", new BABYLON.Vector3(0, 0, 0), scene); var camera = new BABYLON.FreeCamera("baseCamera", new BABYLON.Vector3(0, 0, 0), scene);
this._engine.setHardwareScalingLevel(0.6); this.engine.setHardwareScalingLevel(0.6);
return scene; return scene;
} }
}.bind(this); }.bind(this);
this.scene = createScene(); this.scene = createScene();
this.engine.runRenderLoop(function () { this.engine.runRenderLoop(function () {
this._scene.render(); this.scene.render();
TWEEN.update(); TWEEN.update();
}.bind(this)); }.bind(this));
window.addEventListener("resize", function () { window.addEventListener("resize", function () {
this._engine.resize(); this.engine.resize();
}.bind(this)); }.bind(this));
} }
Object.defineProperty(SceneManager, "ins", { Object.defineProperty(SceneManager, "ins", {
......
{"version":3,"file":"SceneManager.js","sourceRoot":"","sources":["../../src/manager/SceneManager.ts"],"names":[],"mappings":";;AACA;IAgBI;QAEA,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAChD,IAAI,WAAW,GAAC;YACZ;gBAGI,IAAI,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAE5C,0BAA0B;gBAE1B,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,EACpB,CAAC,GAAG,KAAK,CAAC,cAAc,EACxB,CAAC,GAAG,KAAK,CAAC,cAAc,EACxB,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;gBACvC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC;oBAC9C,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC;oBAC9C,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;oBACvC,KAAK,CAAC,YAAY,GAAG,UAAS,CAAC;wBAC3B,KAAK,CAA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AAK,CAAC;aAChB;QACL,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEZ,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,CAAC;QAE3B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACpB,KAAK,CAAC,MAAM,EAAE,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEd,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClB,CAAC;IA7DD,sBAAkB,mBAAG;aAArB;YACI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;aACtC;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;;;OAAA;IA0DF;;QAEI;IAEL;;;;;;;;;;UAUM;IAEG,6BAAM,GAAb,UAAc,OAAO;QAClB;;;;YAII;QAEJ;;aAEK;QAEJ,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAC,EAAE,CAAA;QAEhC;;;;;;;;;;;;;WAaG;QACH,YAAY,CAAC,GAAG,CAAC,KAAK,GAAC,OAAO,CAAC;IACnC,CAAC;IAaL,mBAAC;AAAD,CAAC,AAjID,IAiIC;AAjIY,oCAAY"}
\ No newline at end of file \ No newline at end of file
{ {
"name": "yt", "name": "yt",
"version": "1.0.5", "version": "1.0.6",
"description": "基于Babylonjs的3D框架", "description": "基于Babylonjs的3D框架",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
......
...@@ -23,7 +23,7 @@ export class SceneManager{ ...@@ -23,7 +23,7 @@ export class SceneManager{
{ {
var scene = new BABYLON.Scene(this._engine); var scene = new BABYLON.Scene(this.engine);
//下面的代码是为了设置微信上面的touch事件兼容 //下面的代码是为了设置微信上面的touch事件兼容
...@@ -53,7 +53,7 @@ export class SceneManager{ ...@@ -53,7 +53,7 @@ export class SceneManager{
//下面的代码是为了设置微信上面的touch事件兼容 //下面的代码是为了设置微信上面的touch事件兼容
var camera = new BABYLON.FreeCamera("baseCamera", new BABYLON.Vector3(0, 0, 0), scene); var camera = new BABYLON.FreeCamera("baseCamera", new BABYLON.Vector3(0, 0, 0), scene);
this._engine.setHardwareScalingLevel(0.6) this.engine.setHardwareScalingLevel(0.6)
return scene; return scene;
} }
...@@ -62,12 +62,12 @@ export class SceneManager{ ...@@ -62,12 +62,12 @@ export class SceneManager{
this.scene = createScene(); this.scene = createScene();
this.engine.runRenderLoop(function () { this.engine.runRenderLoop(function () {
this._scene.render(); this.scene.render();
TWEEN.update(); TWEEN.update();
}.bind(this)); }.bind(this));
window.addEventListener("resize", function() { window.addEventListener("resize", function() {
this._engine.resize(); this.engine.resize();
}.bind(this)); }.bind(this));
} }
......
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