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

public scene ...

parent fe924dd3
{
"name": "yt",
"version": "1.0.4",
"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
......@@ -2,8 +2,8 @@
Object.defineProperty(exports, "__esModule", { value: true });
var SceneManager = /** @class */ (function () {
function SceneManager() {
this._canvas = document.querySelector("#renderCanvas");
this._engine = new BABYLON.Engine(this._canvas, true);
this.canvas = document.querySelector("#renderCanvas");
this.engine = new BABYLON.Engine(this.canvas, true);
var createScene = function () {
{
var scene = new BABYLON.Scene(this._engine);
......@@ -33,8 +33,8 @@ var SceneManager = /** @class */ (function () {
return scene;
}
}.bind(this);
this._scene = createScene();
this._engine.runRenderLoop(function () {
this.scene = createScene();
this.engine.runRenderLoop(function () {
this._scene.render();
TWEEN.update();
}.bind(this));
......@@ -52,30 +52,20 @@ var SceneManager = /** @class */ (function () {
enumerable: true,
configurable: true
});
Object.defineProperty(SceneManager.prototype, "scene", {
/* public get stage(): any {
return this._stage;
}*/
get: function () {
return this._scene;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SceneManager.prototype, "canvas", {
get: function () {
return this._canvas;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SceneManager.prototype, "engine", {
get: function () {
return this._engine;
},
enumerable: true,
configurable: true
});
/* 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;
} */
SceneManager.prototype.change = function (display) {
/* console.log(display)
var i;
......
{"version":3,"file":"SceneManager.js","sourceRoot":"","sources":["../../src/manager/SceneManager.ts"],"names":[],"mappings":";;AACA;IAgBI;QAEA,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QACvD,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAClD,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,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC;oBAC/C,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC;oBAC/C,MAAM,CAAC,mBAAmB,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;oBACvC,KAAK,CAAC,YAAY,GAAG,UAAS,CAAC;wBAC3B,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;oBAClC,CAAC;;wBAED,KAAK,CAAC,cAAc,GAAG,UAAS,CAAC;4BAC7B,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;wBAClC,CAAC;;wBAED,KAAK,CAAC,cAAc,GAAG,UAAS,CAAC;4BAC7B,KAAK,CAAC,KAAK,CAAC,CAAC,SA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AAA;QAEZ,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,CAAC;QAE3B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;YACtB,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;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
{
"name": "yt",
"version": "1.0.3",
"version": "1.0.4",
"description": "基于Babylonjs的3D框架",
"main": "./dist/index.js",
"types": "./types/index.d.ts",
......
......@@ -2,9 +2,9 @@
export class SceneManager{
public stage;
private _scene:BABYLON.Scene;
private _canvas;
private _engine;
public scene:BABYLON.Scene;
public canvas;
public engine;
private static instance: SceneManager;
......@@ -17,8 +17,8 @@ export class SceneManager{
constructor(){
this._canvas = document.querySelector("#renderCanvas");
this._engine = new BABYLON.Engine(this._canvas, true);
this.canvas = document.querySelector("#renderCanvas");
this.engine = new BABYLON.Engine(this.canvas, true);
var createScene=function(){
{
......@@ -59,9 +59,9 @@ export class SceneManager{
}
}.bind(this)
this._scene = createScene();
this.scene = createScene();
this._engine.runRenderLoop(function () {
this.engine.runRenderLoop(function () {
this._scene.render();
TWEEN.update();
}.bind(this));
......@@ -75,7 +75,7 @@ export class SceneManager{
return this._stage;
}*/
public get scene(): BABYLON.Scene {
/* public get scene(): BABYLON.Scene {
return this._scene;
}
......@@ -85,7 +85,7 @@ export class SceneManager{
public get engine(): any {
return this._engine;
}
} */
public change(display){
/* console.log(display)
......
export declare class SceneManager {
stage: any;
private _scene;
private _canvas;
private _engine;
scene: BABYLON.Scene;
canvas: any;
engine: any;
private static instance;
static readonly ins: SceneManager;
constructor();
readonly scene: BABYLON.Scene;
readonly canvas: any;
readonly engine: any;
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