Comments (7)
Hi Chau,
translateX is a common function in Object3D ThreeJS class :
https://github.com/mrdoob/three.js/blob/342946c8392639028da439b6dc0597e58209c696/src/core/Object3D.js#L225
PerspectiveCamera extends Camera extends Object3D
Even if I update the camera position properties with a Vector3D I don't see the update on the scene.
I'll go deeper in your code to understand it better. Maybe it would be great to have an example with two buttons moving the camera on click.
from angular-three.
What is translateX
that you're talking about? Can you provide some example? (in vanilla THREE.js is fine)
from angular-three.
Ok, I found a way to do it. I updated my CameraControllerDirective
.
Rather than checking the NgtCanvasInputsStore
(I used the cameraOptions$
Observable), I check NgtStore
and I retrieve the camera$
Observable instead, and it works well.
Initially, I want to use the NgtStore
inside my main component (which creates the NgtCanvas), but I had a Provider error, which is normal, while I'm not in the NgtCanvas context yet. That's why I wanted to create a Camera Controller Directive.
This directive will be able to listen for state or route change, in a way or another, to update the camera position.
This way :
@Directive({
selector: 'camera-controller'
})
export class CameraControllerDirective {
constructor(
private store: NgtStore
) {
this.store.selectors.camera$
.subscribe(camera => {
if (camera) {
camera.translateX(20);
}
});
}
}
I'll add greensock in my project to update smoothly the position.
I you want I can create a simple new example in angular-three to show how to update camera position.
from angular-three.
Nice! Go for it. Check out the demo
to see how you can work with a demo and get a story going for it. I'd love to see it
from angular-three.
What do you think if I add greensock as a dependency to get animated things ?
from angular-three.
if you add it to the root package.json, it will be added as a dependency to the monorepo which is fine. Only the demo
app uses it right? The libraries' package.json should keep clean.
Now, the thing with greensock, I've been evaluating whether to use greensock or popmotion to support spring animation to Angular Three. Maybe you have better experience in this space than mine :D What do you think? We can make a new issue/discussion to discuss that piece
from angular-three.
Yes I plan to use it only in the demo
app.
I know Greensock very well, I use it since years while I was working with Flash/Flex, on Real Time 3D projects too (an example, 2011, YouTube screen capture), with Stage3D. I didn't try to use popmotion yet but Greensock allows to do huge things.
I think the animation lib choice is up to the final user. Maybe we could get some examples with greensock, others with a challenger.
from angular-three.
Related Issues (20)
- Support for threejs r141 HOT 4
- Error: export 'XRRigidTransform' (imported as 'XRRigidTransform') was not found in 'three' HOT 4
- [Feature] Method to remove physics body HOT 1
- [Bug?/Feature] Missing loader objects HOT 5
- [Bug] Objects not added to scene after Enter VR on Oculus Quest HOT 1
- NgtPrimitiveModule not working. "'ngt-primitve' is not a known element" HOT 5
- Angular 14 support HOT 5
- THREE.WebGLRenderer: Context Lost. HOT 1
- 6.0.0-beta HOT 5
- Missing LUT3DEffect error HOT 4
- Cannon JS problem HOT 1
- How to import an glb object with no gemotery prop in node HOT 2
- Can't access useBody internal UUID when adding constraints against instance mesh bodies HOT 2
- NgtSobaOrbitControls missing update HOT 2
- QUESTION: Porting/Wrapping different physics engine "Force Directed layout in 3D" as a new component HOT 2
- THREE.MeshStandardMaterial: 'Uniform' is not a property of this material issue HOT 1
- Cannot load two same GLTF models in component HOT 1
- Bug - Soba Text whiteSpace
- How to deal with the disappearance of gizmo after adding NgtEffectComposer effects? HOT 2
- Issue with achieving the same result as with Threejs HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-three.