Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem loading viewerA scene into viewerB scene #168

Open
GoogleCodeExporter opened this issue Jul 29, 2015 · 1 comment
Open

Problem loading viewerA scene into viewerB scene #168

GoogleCodeExporter opened this issue Jul 29, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hi, I am building an aplication that should a grid of mini viewers. If user 
clicks on one of the miniatures, tha miniature's scene should be loaded into a 
bigger viewer.

I could get several miniviewers to load objects into a grid, 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:38

@GoogleCodeExporter
Copy link
Author

Reported twice. Please cancel this issue and see issue 168

Original comment by [email protected] on 28 Jul 2015 at 3:46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant