You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am building an aplication that should have a grid of miniature viewers.
If user clicks on one of the miniatures, that miniature's scene should be
loaded into a bigger viewer.
I could get several miniviewers in a grid to load objects, initialize the
bigger viewer and even create a scene for the bigger one using the one from the
smaller one. Bigger's scene goes from null to a scene object. However, the
scene is not displayed.
This is an example of whatI am trying to do:
--------------------------------------------
var mainCanvas = document.getElementById('cav');
var canvas1 = document.getElementById('cav1');
var mainViewer = new JSC3D.Viewer(mainCanvas);
var viewer1 = new JSC3D.Viewer(canvas1);
var components = [{members of the scene}]
var scene1 = new JSC3D.Scene("scene1");
var numOfLoaded = 0;
var onModelLoaded = function (scene) {
var meshes = scene.getChildren();
for (var i = 0; i < meshes.length; i++) {
scene1.addChild(meshes[i]);
if (meshes.length > 0)
meshes[0].setMaterial(new JSC3D.Material('new_material', 0, colors.WHITE));
}
if (++numOfLoaded == components.length)
viewer1.replaceScene(scene1);
};
for (var i = 0; i < components.length; i++) {
var loader = new JSC3D.ObjLoader;
loader.onload = onModelLoaded;
loader.loadFromUrl(components[i]);
}
/**** UP TO HERE, IT WORKS SUPERBLY ****/
mainViewer.setParameter('InitRotationX', 0);
mainViewer.setParameter('InitRotationY', 0);
mainViewer.setParameter('InitRotationZ', 0);
mainViewer.setParameter('RenderMode', 'texturesmooth');
mainViewer.setParameter('MipMapping', 'on');
mainViewer.setParameter('ProgressBar', 'on');
mainViewer.setParameter('Renderer', 'webgl');
mainViewer.init();
mainViewer.update();
viewer1.setParameter('InitRotationX', 0);
viewer1.setParameter('InitRotationY', 0);
viewer1.setParameter('InitRotationZ', 0);
viewer1.setParameter('RenderMode', 'texturesmooth');
viewer1.setParameter('MipMapping', 'on');
viewer1.setParameter('ProgressBar', 'on');
viewer1.setParameter('Renderer', 'webgl');
viewer1.init();
viewer1.update();
viewer1.onmousedown = function () {
var meshes = viewer1.getScene().getChildren();
var newScene = new JSC3D.Scene("newScene");
for (var i = 0; i < meshes.length; i++) {
var mesh = new JSC3D.Mesh(
meshes[i].name,
meshes[i].visible,
meshes[i].material,
meshes[i].texture,
meshes[i].creaseAngle,
meshes[i].isDoubleSided,
meshes[i].isEnvironmentCast,
meshes[i].coordBuffer,
meshes[i].indexBuffer,
meshes[i].textCoordBuffer,
meshes[i].textCoordIndexBuffer);
mesh.setMaterial(meshes[i].material);
mesh.init();
newScene.addChild(mesh);
}
mainViewer.replaceScene(newScene);
};
Can anybody see why this is not working?
An if there is a way to directly share the same scene in both viewers, it would
be even better, as for the big viewer is intended to edit the scene, and it
would be great that those changes were to be shown on the mini viewer.
I REALY AM DESPERATE!
THANKS IN ADVANCE FOR YOUR COOPERATION!!
Original issue reported on code.google.com by [email protected] on 27 Jul 2015 at 8:43
The text was updated successfully, but these errors were encountered:
I could solve it.
If anybody comes with this problem, change above example code to:
viewer1.onmousedown = function () {
var meshes = viewer1.getScene().getChildren();
var newScene = new JSC3D.Scene();
for (var i = 0; i < meshes.length; i++) {
newScene.addChild(meshes[i]);
}
mainViewer.replaceScene(newScene);
mainViewer.setParameter('InitRotationX', 0);
mainViewer.setParameter('InitRotationY', 0);
mainViewer.setParameter('InitRotationZ', 0);
mainViewer.setParameter('RenderMode', 'texturesmooth ');
mainViewer.setParameter('MipMapping', 'on');
mainViewer.setParameter('ProgressBar', 'on');
mainViewer.setParameter('Renderer', 'webgl');
mainViewer.update();
};
Moreover, replace the previous
mainViewer.setParameter('InitRotationX', 0);
mainViewer.setParameter('InitRotationY', 0);
mainViewer.setParameter('InitRotationZ', 0);
mainViewer.setParameter('RenderMode', 'texturesmooth');
mainViewer.setParameter('MipMapping', 'on');
mainViewer.setParameter('ProgressBar', 'on');
mainViewer.setParameter('Renderer', 'webgl');
mainViewer.init();
mainViewer.update();
with only
mainViewer.init();
Original issue reported on code.google.com by
[email protected]
on 27 Jul 2015 at 8:43The text was updated successfully, but these errors were encountered: