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

up

parent ae4bc527
{
"name": "yt",
"version": "1.0.2",
"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
{
"name": "yt",
"version": "1.0.3",
"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;
private _scene:BABYLON.Scene;
private _canvas;
private _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()
}
/*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
export class SceneManager{
public stage;
private _scene:BABYLON.Scene;
private _canvas;
private _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
......@@ -82,10 +82,10 @@ var SceneManager = /** @class */ (function () {
for(i in display){
console.log(display[i])
}*/
for (var _i = 0, _a = SceneManager.ins.scene.meshes; _i < _a.length; _i++) {
var l = _a[_i];
l.dispose();
}
/* 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])
......
{"version":3,"file":"SceneManager.js","sourceRoot":"","sources":["../../src/manager/SceneManager.ts"],"names":[],"mappings":";;AACA;IAgBI;QAEA,IAAI,CAAC,OAAO,GAAG,QAAQ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B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACrB,KAAK,CAAC,MAAM,EAAE,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAEd,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE;YAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1B,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;IA8DD,sBAAW,+BAAK;QAJjB;;YAEI;aAEH;YACI,OAAO,IAAI,CAAC,MAAM,CAAC;QACvB,CAAC;;;OAAA;IAED,sBAAW,gCAAM;aAAjB;YACI,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;;;OAAA;IAED,sBAAW,gCAAM;aAAjB;YACI,OAAO,IAAI,CAAC,OAAO,CAAC;QACxB,CAAC;;;OAAA;IAEM,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
{
"name": "yt",
"version": "1.0.1",
"version": "1.0.3",
"description": "基于Babylonjs的3D框架",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
......
......@@ -94,9 +94,11 @@ export class SceneManager{
console.log(display[i])
}*/
for(var l of SceneManager.ins.scene.meshes){
/* for(var l of SceneManager.ins.scene.meshes){
l.dispose()
}
} */
SceneManager.ins.scene.meshes=[]
/*var j;
for(j in SceneManager.ins.stage){
......
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