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

Render Loop does not work with GltfModel #115

Closed
lordLegal opened this issue Dec 26, 2021 · 1 comment
Closed

Render Loop does not work with GltfModel #115

lordLegal opened this issue Dec 26, 2021 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@lordLegal
Copy link

I am trying to let a Model move but the value is changing but the renderer does not update.

<template>
  <Renderer ref="renderer" antialias orbit-ctrl resize="window">
    <Camera ref="cam" :position="{ z: 40, x: 3 }"></Camera>
    <Scene ref="scene" :background="'white'">
      <AmbientLight color="#808080"></AmbientLight>
      <PointLight color="#ffffff" :position="{ y: 50, z: 0 }"></PointLight>
      <PointLight color="#ffffff" :position="{ y: -50, z: 0 }"></PointLight>
      <PointLight color="#ffffff" :position="{ y: 0, z: 0 }"></PointLight>
      <GltfModel
        ref="model"
        :rotation="{ y: 0, z: 0 }"
        src="http://192.168.178.23:8080/car.gltf"
      />
    </Scene>
  </Renderer>
</template>

<script>
import {
  Camera,
  PointLight,
  Renderer,
  Scene,
  GltfModel,
  AmbientLight,
} from "troisjs";
export default {
  name: "Car",
  components: { Camera, PointLight, Renderer, Scene, GltfModel, AmbientLight },
  mounted() {
    const renderer = this.$refs.renderer;
    const box = this.$refs.model;
    //var cam = this.$refs.cam
    //var scene = this.$refs.scene
    renderer.onBeforeRender(() => {
      console.log(box);
      box.rotation.y += 1;
    });
  },
};
</script>



<style >
canvas {
  width: 100%;
  height: 100%;
}
</style> 
@klevron klevron self-assigned this Jan 4, 2022
@klevron klevron added this to the 0.3.4 milestone Jan 4, 2022
@klevron klevron added the documentation Improvements or additions to documentation label Feb 16, 2022
@klevron
Copy link
Member

klevron commented Feb 16, 2022

You should try :

const renderer = this.$refs.renderer
const model = this.$refs.model
renderer.onBeforeRender(() => {
  if(model.o3d) model.o3d.rotation.y += 0.1
})

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

No branches or pull requests

2 participants