Commit efa65aba authored by 任建锋's avatar 任建锋

优化scene

parent 7f300826
{
"name": "yt",
"version": "1.0.17",
"description": "基于Babylonjs的3D框架",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
"scripts": {
},
"author": "",
"license": "ISC",
"dependencies": {
"duiba-tc": "git+ssh://git@gitlab2.dui88.com:clq/tc.git#1.0"
}
}
\ No newline at end of file
export class YtSceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas=document.querySelector("#renderCanvas");;
public engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});
private static instance: YtSceneManager;
public static get ins(): YtSceneManager {
if (!this.instance) {
this.instance = new YtSceneManager();
}
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);
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()
} */
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
export class YtSceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas=document.querySelector("#renderCanvas");
public engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});
private static instance: YtSceneManager;
public static get ins(): YtSceneManager {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
}
constructor(){
// this.canvas = document.querySelector("#renderCanvas");
// this.engine = new BABYLON.Engine(this.canvas, true);
this.engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});
this.scene = this.createScene();
this.engine.runRenderLoop(function () {
this.scene.render();
TWEEN.update();
}.bind(this));
window.addEventListener("resize", function() {
this.engine.resize();
}.bind(this));
}
public createScene(){
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);
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
export class YtSceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas=document.querySelector("#renderCanvas");
public engine;
private static instance: YtSceneManager;
public static get ins(): YtSceneManager {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
}
constructor(){
// this.canvas = document.querySelector("#renderCanvas");
// this.engine = new BABYLON.Engine(this.canvas, true);
this.engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});
this.scene = this.createScene();
this.engine.runRenderLoop(()=>{
this.scene.render();
TWEEN.update();
});
window.addEventListener("resize", ()=> {
this.engine.resize();
});
}
public createScene(){
var scene = new BABYLON.Scene(this.engine);
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);
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
export class YtSceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas:any=document.querySelector("#renderCanvas");
public engine;
private static instance: YtSceneManager;
public static get ins(): YtSceneManager {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
}
constructor(){
// this.canvas = document.querySelector("#renderCanvas");
// this.engine = new BABYLON.Engine(this.canvas, true);
this.engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});
this.scene = this.createScene();
this.engine.runRenderLoop(()=>{
this.scene.render();
TWEEN.update();
});
window.addEventListener("resize", ()=> {
this.engine.resize();
});
}
public createScene(){
var scene = new BABYLON.Scene(this.engine);
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);
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
export class YtSceneManager{
public stage;
public scene:BABYLON.Scene;
public canvas:any=document.querySelector("#renderCanvas");
public engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});;
private static instance: YtSceneManager;
public static get ins(): YtSceneManager {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
}
constructor(){
this.init()
}
public init(){
this.scene = this.createScene();
this.engine.runRenderLoop(()=>{
this.scene.render();
TWEEN.update();
});
window.addEventListener("resize", ()=> {
this.engine.resize();
});
}
public createScene(){
var scene = new BABYLON.Scene(this.engine);
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);
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
...@@ -3,15 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true }); ...@@ -3,15 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
var YtSceneManager = /** @class */ (function () { var YtSceneManager = /** @class */ (function () {
function YtSceneManager() { function YtSceneManager() {
this.canvas = document.querySelector("#renderCanvas"); this.canvas = document.querySelector("#renderCanvas");
// this.engine = new BABYLON.Engine(this.canvas, true);
this.engine = new BABYLON.Engine(this.canvas, true, { this.engine = new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true, deterministicLockstep: true,
lockstepMaxSteps: 2 lockstepMaxSteps: 2
}); });
var createScene = function () { this.init();
{ }
;
Object.defineProperty(YtSceneManager, "ins", {
get: function () {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
},
enumerable: true,
configurable: true
});
YtSceneManager.prototype.init = function () {
var _this = this;
this.scene = this.createScene();
this.engine.runRenderLoop(function () {
_this.scene.render();
TWEEN.update();
});
window.addEventListener("resize", function () {
_this.engine.resize();
});
};
YtSceneManager.prototype.createScene = function () {
var scene = new BABYLON.Scene(this.engine); var scene = new BABYLON.Scene(this.engine);
//下面的代码是为了设置微信上面的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),
this.canvas.removeEventListener(a + "down", o), this.canvas.removeEventListener(a + "down", o),
...@@ -34,27 +55,7 @@ var YtSceneManager = /** @class */ (function () { ...@@ -34,27 +55,7 @@ var YtSceneManager = /** @class */ (function () {
//下面的代码是为了设置微信上面的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);
return scene; 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));
}
Object.defineProperty(YtSceneManager, "ins", {
get: function () {
if (!this.instance) {
this.instance = new YtSceneManager();
}
return this.instance;
},
enumerable: true,
configurable: true
});
/* public get stage(): any { /* public get stage(): any {
return this._stage; return this._stage;
}*/ }*/
......
{"version":3,"file":"YtSceneManager.js","sourceRoot":"","sources":["../../src/manager/YtSceneManager.ts"],"names":[],"mappings":";;AACA;IAgBI;QAEA,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACvD,uDAAuD;QACtD,IAAI,CAAC,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE;YAChD,qBAAqB,EAAE,IAAI;YAC3B,gBAAgB,EAAE,CAAC;SACtB,CAAC,CAAC;QACC,IAAI,WAAW,GAAC;YACZ;gBAGI,IAAI,KAAK,GAAG,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAE3C,0BAA0B;gBAE1B,IAAI,CAAC,GAAG,KAAK,CAAC,YAAY,EACpB,CAAC,GAAG,KAAK,CAAC,cAAc,EACxB,CAAC,G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{
"name": "yt", "name": "yt",
"version": "1.0.16", "version": "1.0.17",
"description": "基于Babylonjs的3D框架", "description": "基于Babylonjs的3D框架",
"main": "./dist/index.js", "main": "./dist/index.js",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
......
...@@ -3,8 +3,11 @@ export class YtSceneManager{ ...@@ -3,8 +3,11 @@ export class YtSceneManager{
public stage; public stage;
public scene:BABYLON.Scene; public scene:BABYLON.Scene;
public canvas; public canvas:any=document.querySelector("#renderCanvas");
public engine; public engine=new BABYLON.Engine(this.canvas, true, {
deterministicLockstep: true,
lockstepMaxSteps: 2
});;
private static instance: YtSceneManager; private static instance: YtSceneManager;
...@@ -16,21 +19,22 @@ export class YtSceneManager{ ...@@ -16,21 +19,22 @@ export class YtSceneManager{
} }
constructor(){ constructor(){
this.init()
}
this.canvas = document.querySelector("#renderCanvas"); public init(){
// this.engine = new BABYLON.Engine(this.canvas, true); this.scene = this.createScene();
this.engine = new BABYLON.Engine(this.canvas, true, { this.engine.runRenderLoop(()=>{
deterministicLockstep: true, this.scene.render();
lockstepMaxSteps: 2 TWEEN.update();
}); });
var createScene=function(){ window.addEventListener("resize", ()=> {
{ this.engine.resize();
});
}
public createScene(){
var scene = new BABYLON.Scene(this.engine); var scene = new BABYLON.Scene(this.engine);
//下面的代码是为了设置微信上面的touch事件兼容
var n = scene._onPointerUp var n = scene._onPointerUp
, o = scene._onPointerDown , o = scene._onPointerDown
, r = scene._onPointerMove , r = scene._onPointerMove
...@@ -53,26 +57,10 @@ export class YtSceneManager{ ...@@ -53,26 +57,10 @@ export class YtSceneManager{
this.canvas.addEventListener(a + "move", scene._onPointerMove, !1), this.canvas.addEventListener(a + "move", scene._onPointerMove, !1),
this.canvas.addEventListener(a + "down", scene._onPointerDown, !1), this.canvas.addEventListener(a + "down", scene._onPointerDown, !1),
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);
return scene; 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 { /* public get stage(): any {
return this._stage; return this._stage;
......
...@@ -2,9 +2,11 @@ export declare class YtSceneManager { ...@@ -2,9 +2,11 @@ export declare class YtSceneManager {
stage: any; stage: any;
scene: BABYLON.Scene; scene: BABYLON.Scene;
canvas: any; canvas: any;
engine: any; engine: BABYLON.Engine;
private static instance; private static instance;
static readonly ins: YtSceneManager; static readonly ins: YtSceneManager;
constructor(); constructor();
init(): void;
createScene(): BABYLON.Scene;
change(display: any): void; 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