hello, on chrome browser i’m trying to track zoom distance.
I took the scene “Model viewer test scene”
https://playcanvas.com/editor/scene/784896
and basically use the same scripts but disabled the pan.
similar to the project i take the field ‘distance’ from OrbitCamera
same way OrbitMouseInput does using
var OverZoom = pc.createScript('overZoom');
// initialize code called once per entity
OverZoom.prototype.initialize = function() {
this.orbitCamera = this.entity.script.orbitCamera;
var fix;
};
// update code called every frame
OverZoom.prototype.update = function(dt) {
fix = this.orbitCamera.distance;
//console.log("current zoom is "+this.orbitCamera.distance);
};
the problem is that whenever i zoom, i do get zoom to contain the distance, but also recieve errors from chrome.
I looked on the web and the best solution was to replace scripts locally
not a solution that can work outside the development phase.
have you encountered it? is there a solution I can implement in the scene, script or project?
reproduction:
- create a project from https://playcanvas.com/project/629759/overview/model-viewer-test-scene this
- add to the camera a script called OverZoom and paste this code
var OverZoom = pc.createScript('overZoom');
// initialize code called once per entity
OverZoom.prototype.initialize = function() {
this.orbitCamera = this.entity.script.orbitCamera;
var fix;
};
// update code called every frame
OverZoom.prototype.update = function(dt) {
fix = this.orbitCamera.distance;
//console.log("current zoom is "+this.orbitCamera.distance);
};
- play the scene and zoom with wheel