Hi there,
following you can see the script-snippet from my rookie vue-application
export default {
data: () => ({
canvas: null,
scene: null,
sceneToRender: null,
engine: null,
camera: null,
environment: null,
lights:[],
}),
methods:{
createEngine(canvas){
console.log("- create Engine");
var createDefaultEngine = function(){
return new BABYLON.Engine(canvas,true,{
preserveDrawingBuffer: true,
stencil: true,
disableWebGL2Support: false
});
};
try {
return createDefaultEngine();
} catch {
console.log("The available createEngine-Function failed.");
return createDefaultEngine();
}
},
createCamera(scene){
console.log("- create Camera");
var camera = new BABYLON.ArcRotateCamera(
"camera",
(0.8 * -Math.PI)/2,
(1.2 * Math.PI)/4,
10,
new BABYLON.Vector3(0,0,0),
scene
);
camera.attachControl(this.canvas,false);
this.camera = camera;
},
createLight(scene){
console.log("- create Light");
var light = new BABYLON.HemisphericLight("light",new BABYLON.Vector3(2,10,6),scene);
this.lights = light;
},
createEnvironment(scene){
console.log("- create Environment");
this.environment = scene.createDefaultEnvironment({
enableGroundShadow: true,
groundYBias: 1,
});
this.environment.setMainColor(BABYLON.Color3.Purple);
},
createScene(){
console.log("create Scene:");
this.canvas = document.getElementById("babylon-canvas");
this.engine = this.createEngine(this.canvas);
var scene = new BABYLON.Scene(this.engine);
// scene.clearColor = new BABYLON.Color3.Purple;
this.createCamera(scene);
this.createLight(scene);
this.createEnvironment(scene);
return scene;
}
},
mounted(){
this.scene = this.createScene();
this.sceneToRender = this.scene;
var frameNo = 0;
this.engine.runRenderLoop(() => {
frameNo++;
if(this.sceneToRender && this.sceneToRender.activeCamera){
console.log("FrameNo.: " + frameNo);
this.sceneToRender.render();
}
});
}
}
Many parts were copied from an older application. But when i run the app, there is this error and i can not find the problem. It occurse after 4-5 frames/renderloops.
babylon.js?633b:16 Uncaught TypeError: i.toArray is not a function
at e._updateColor4ForUniform (babylon.js?633b:16)
at t.bindForSubMesh (babylon.js?633b:16)
at t.render (babylon.js?633b:16)
at e.render (babylon.js?633b:16)
at e.renderUnsorted (babylon.js?633b:16)
at e.render (babylon.js?633b:16)
at e.render (babylon.js?633b:16)
at t._renderForCamera (babylon.js?633b:16)
at t._processSubCameras (babylon.js?633b:16)
at t.render (babylon.js?633b:16)
Thanks for your help. Maybe I am just a bit blind…