Forum Replies Created
-
AuthorPosts
-
jdockCustomer
Thanks Alexander – I gave that a shot with the same results. My project has an opening scene with hidden objects that I clone to build the design. I also checked my Blender colors and I have the GLTF 2.0 compatible setting correct. Here’s the link: https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:ee6098fa38/applications/ShoreStationDock/index.html
jdockCustomerCorrect – I believe just the object name will work. A few post in this thread I show how I modified the visual_logic.js to get it to work. I believe what I did there just returns the name, not the actual js object. This workaround works, but I want to avoid editing the visual_logic code if possible.
Thanks,
JonjdockCustomerYuri,
Is there an issue if you added the functionality to the ‘when clicked’ event to return the mesh object name in PickedObject even if it is not the target of the When Clicked event? I know it is not the intent of the When Clicked, but it was how it worked prior to 3.5.
If this is not possible, maybe some help developing a ‘Get Picked’ puzzle. The issue is really for projects like mine where a lot of cloning is involved and an elegant way of interacting with the cloned objects is needed. Basically I need a puzzle to just return PickedObject no matter what mesh is picked. This avoids creating a bunch of When Clicked events for each clone. I used conditions based on the mesh name to determine actions. If you are careful with the mesh names (like using a . at the end of the name) the clone name is predictable.
Thanks,
JonjdockCustomerYuri,
I tried something slightly different. If you look at the visual_logic.js content and go to the function initObjectPicking function inside registerOnClick, this changed from 3.4 to 3.5:
if (!isPicked) {
_pGlob.pickedObject = ”;
cbIfMissedDo(event);
}if I change this to as it was in 3.4, any intersected object from the mouse event gets returned with PickedObject, but isPicked remains false:
if (!isPicked) {
_pGlob.pickedObject = objName;
cbIfMissedDo(event);
}
I changed this in the visual_logic.js and it works as before. Any chance this could be put back into 3.5? If not, I can just remember to tweak it.
Thanks,
JonjdockCustomerYuri,
I have having difficulty getting the ‘code puzzle’ to work with the 3D embedded. I have the 3D window in an iframe with an id = 3dFrame. I seem to be getting the correct mouse coordinates, but the raycaster doesn’t seem to intersect anything. Any ideas?
Here’s my attempt to refer to the embedded window height and width:
`// Built-in variables: app, v3d, VARS, PROC
var mouse = new v3d.Vector2();
var raycaster = new v3d.Raycaster();
var x = document.getElementsByName(‘3dFrame’);
mouse.set((VARS[‘mouseX’] / x.innerWidth) * 2 – 1, – (VARS[‘mouseY’] / x.innerHeight) * 2 + 1);
raycaster.setFromCamera(mouse, app.camera);var intersects = raycaster.intersectObjects(app.scene.children);
if (intersects.length > 0) {
VARS[‘temp’] = intersects[0].object.name;
} else {
VARS[‘temp’] = null;
}Jon
jdockCustomerOK, so I did find a workaround: The attached puzzle worked (not in the preview window though). The code in the ‘Exec Script’ puzzle is:
// Built-in variables: app, v3d, VARS, PROC
var mouse = new v3d.Vector2();
var raycaster = new v3d.Raycaster();
mouse.set((VARS[‘mouseX’] / window.innerWidth) * 2 – 1, – (VARS[‘mouseY’] / window.innerHeight) * 2 + 1);
raycaster.setFromCamera(mouse, app.camera);var intersects = raycaster.intersectObjects(app.scene.children);
if (intersects.length > 0) {
VARS[‘temp’] = intersects[0].object.name;
} else {
VARS[‘temp’] = null;
}This returns the name of the mesh if hit, or null if not.
Thanks,
JonAttachments:
You must be logged in to view attached files.jdockCustomerYuri,
I gave this a try. I created a list called ‘AllObjects’ and added all mesh objects to it. I have attached the puzzle where I add any new cloned objects to the ‘AllObjects’ list. It seems the When Clicked event does not see the change to the list. It looks like the event only pays attention to the contents of the list when it is initiated – correct?
Thanks,
JonAttachments:
You must be logged in to view attached files.jdockCustomerIf the ’empty when clicked’ approach is bad, maybe some guidance in creating a custom event handler that just returns the mesh name from any click?
jdockCustomerHere’s 3.5
jdockCustomerHere are the two versions. CloneTest.zip if from 3.4, CloneTest35.zip is from 3.5.
jdockCustomerThanks guys – browser cache did not seem to affect the behavior, but a good thought.
Yuri, I know this is an odd approach, but in 3.4 and prior, the picked object always returned the mesh name. I put an example of 3.4 with this puzzle attached. Check out the console output. I was careful to name the original mesh Cube.0 so the clone name would be predictable (Cube.1, Cube.2, etc.). Here’s the 3.4 example: https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:091950d814/applications/CloneTest/CloneTest.html
Here’s the exact same in 3.5: https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:ff74dcf89a/applications/CloneTest35/CloneTest.htmlJust updating the project after upgrade to 3.5 does not affect the behavior, but changing a puzzle and saving does.
Again, if this is a terrible approach, I am open to other ideas to be able to capture click events of cloned objects. Here’s my production project that involves a lot of cloning: https://cdn.soft8soft.com/AROAJSY2GOEHMOFUVPIOE:ff74dcf89a/applications/ShoreStationDock/index.html
Perhaps a custom routine? I’m not a great coder, so I’d need help:)
Thanks,
JonjdockCustomerWorked perfectly. Thanks!
jdockCustomerGreat – thanks for the quick response!
I am a little new to Verge3D support – should these issues come to the forums, or should I email them to tech support?
jdockCustomerYuri,
Thanks for the reply – the issue is not being able to switch cameras, but changing the size of the camera. If I resize the window containing the 3DSection and perform a screen shot, I get an image with an aspect ratio of the window. I am curious if there is a blender or camera setting to change the aspect ratio through a puzzle or javascript.
Thanks,
JonjdockCustomerThanks for your help!
-
AuthorPosts