Can you have 2 controllers in 3JS? - animation

I am very fresh to 3JS.
I have a room with an Orbital Controller.
In this room there is a jacket(not center), which I need it to move with the mouse and spin. Now I think Orbital Control would work, but I already have one controlling the room. My work wants this jacket to rotate like this : https://codesandbox.io/s/mixing-html-and-webgl-w-occlusion-9keg6?file=/src/App.js:1634-1641
Which uses an orbital controller.
How can I achieve this ?
Hope someone can help

Related

Making clickable areas on a 3D model in Three js

I'm creating a webpage for a new beer brand for gamers.
So far, I've created a spinning beer can in Three js. I found a GLTF model, made a texture, added lighting and reflections - all the simple basics - using Drei and Fiber.
What I would love to achieve right now, is to use the beer can as navigation for the page. So if you mouse over the logo on the face of the can, the logo should change color to indicate you can click it, and if you click it, something happens (let's say a modal opens). You can then spin the can around and click different parts of it (some text, an icon, the barcode, etc) to get different content.
I'm not sure how I would achieve this or approach this. I've had a couple of different thoughts:
Map up clickable areas on the model somehow. This didn't seem possible.
Make all the different clickable parts separate objects in the model. This seems like a ton of work, and I'd have to spend a lot of time learning Blender. The can model is pretty simple (used a free one from sketchfab.com for now).
Map up html-elements onto the can using css3drenderer. But I didn't find a way to bend it onto the can well, and it didn't seem like I could use the model for that.
Use many textures with alphas on top of each other on the can and somehow look for transparency on click for each layer. Didn't find any way to do this.
Any ideas on what techniques to use to achieve this? I've done game dev in Unity, but I'm new to Three js and WebGL, so it's really hard to know where to start searching.
The common approach is to use raycasting to detect interaction with a model.
What you're really looking for is a hyperlink. Although you can't manually apply a hyperlink to three.js, you can use THREE.Raycaster() as a loophole.
Once you determine that the model was clicked on, you just do the following to redirect the user:
window.location.href = 'https://example.com/'
That should do it~
EDIT:
Here is an example, based on my reply to your comment:
if(intersects.length > 0){
if(intersects[0] == model.children[2]){ //Second child
window.location.href = 'https://example.com/'
}
}

How do I put an interactable Canvas onto a 3D game object?

Is it possible to place a UI Canvas onto a 3D object? I'd like to create a cash dispenser machine (for example) with a user interface that can be interacted with. Then there will be keycode locks on doors, touchscreen computers, etc.
How can I display a canvas as a 3D object in the 3D world and still have it interactable? Placing it on a Plane would be good enough.
Yes, it is possible. Change Canvas Render Mode to World Space then drag your Camera into the Event Camera slot. You will have to find select the Canvas, press F in Scene View to find it then move it to the place you want it to be.
You need to use World Space UI. Can place anywhere in scene but make sure use can view it in order to interact.
To learn more, watch this video : https://blogs.unity3d.com/2014/06/30/unity-4-6-new-ui-world-space-canvas/

Not able to run unity 3d app properly

I have just started to learn Unity 3D. I am using this as first lesson. I created a terrain, added texture, plants and grasses, added first person controller and directional lighting. When I press play, the scene automatically starts moving along Y direction. I want the scene to move only when i give input using keyboard or mouse. How to achieve this ?
The first person controller has to be placed above the terrain completely. After doing this I get the desired effect.

camera.lookAt not called when THREE controls are being used

I am working on a program, that uses THREE.RollControls, when the user goes too far away from the center of the screen, they tend to get lost, so I am working on creating a function that reorients them, facing the center of the scene.
What I had intened to do was simply call the following:
camera.lookAt(scene.position)
However, this has no affect. From what I was reading on different stack overflow questions specifically this:
ThreeJS camera.lookAt() has no effect, is there something I'm doing wrong?
It seems like their solution was to do the camera position change using the controls, rather then changing the camera itself.
I do not believe there is any 'Target' in the Roll Controls, so I don't know how I can reset where the camera is looking at based on a THREE.Vector3() Is there a simple way to do this, or will I basically have to:
So far I have 'attempted' to do the follow:
- Calculate the difference of position of the camera with the position of the scene.
- Normalize this vector
- Subtract it from the direction forward of the camera
- use this vector in controls.forward.add(thisVector)
but this doesn't do at all what I want (probably because I have no idea what I'm doing)
Thank you in advance for your time!
Isaac
The same thing bugged me too about the RollControls but I took a different approach in solving the problem. Since the controls are in the example code (in r55) you can modify the controls, as they are not part of the core library. You can see my modifications at http://www.virtuality.gr/AGG/EaZD-WebGL/js/three.js/examples/js/controls/RollControls.js
I introduced a local variable called mouseLook because I could not use the this.mouseLook. I initialized it to false and I only make it true when there is a button press i.e. when navigating in the scene. That solved my problem.

How to make a sort of scratchboard in flash?

I was wondering if someone could teach me how to make a scene in flash where you have an image on top of the other, and you can scratch the top one off to show what's below.
Kinda like those prize cards where you have to scratch the silver thing to see if there's a prize below.
Anyone has any idea if this is even possible in flash?
Yes it's possible, here is one example. I'm sure there are others.
The concept is that you use a mask to hide the image. Then use a mouse move event listener to draw on the mask as the user mouses over the object. Parts of the mask that have something on them (ie: the stuff you're drawing in the mouse move listener) will then reveal the underlying object that was being masked.

Resources