Orillusion / orillusion

Orillusion is a pure Web3D rendering engine which is fully developed based on the WebGPU standard.
https://www.orillusion.com
MIT License
4.7k stars 614 forks source link

[BUG]: 第一次渲染时onLateUpdate会在onUpdate之前调用 #221

Closed gonlyk closed 7 months ago

gonlyk commented 1 year ago

Bug描述

简单明晰的描述问题所在

Bug复现流程

期待的结果

应先执行update

报错截图

image

测试引擎版本:

0.6.3

本机系统 (请填写完整):

代码示例

import {
  Engine3D,
  Scene3D,
  AtmosphericComponent,
  Object3D,
  Camera3D,
  ComponentBase,
  HoverCameraController,
  DirectLight,
  MeshRenderer,
  BoxGeometry,
  LitMaterial,
  View3D,
} from "@orillusion/core";

Engine3D.init().then(() => {
  const scene3D = new Scene3D();
  // 添加大气散射天空组件
  const sky = scene3D.addComponent(AtmosphericComponent);

  // 新建摄像机实例
  let cameraObj = new Object3D();
  let camera = cameraObj.addComponent(Camera3D);
  // 根据窗口大小设置摄像机视角
  camera.perspective(60, window.innerWidth / window.innerHeight, 1, 5000.0);
  // 设置相机控制器
  let controller = camera.object3D.addComponent(HoverCameraController);
  controller.setCamera(0, 0, 15);
  // 添加相机节点
  scene3D.addChild(cameraObj);
  // 新建光照
  let light = new Object3D();
  // 添加直接光组件
  let component = light.addComponent(DirectLight);
  // 调整光照参数
  light.rotationX = 45;
  light.rotationY = 30;
  component.intensity = 2;
  // 添加光照对象
  scene3D.addChild(light);
  // 新建对象
  const obj = new Object3D();
  let mr = obj.addComponent(MeshRenderer);
  mr.geometry = new BoxGeometry(5, 5, 5);
  mr.material = new LitMaterial();

  let i = 0;
  obj.addComponent(
    class extends ComponentBase {
      start() {
        this.transform.rotationY = 0.0;
      }
      onUpdate() {
        i += 1;
        this.transform.rotationY += 1.0;
        console.log("call onUpdate");
        console.log("rotationY ", this.transform.rotationY);
      }
      onLateUpdate() {
        console.log("call onLateUpdate");
        console.log("rotationY in late", this.transform.rotationY);
        console.log("i ", i);
      }
    }
  );
  scene3D.addChild(obj);
  // 创建View3D对象
  let view = new View3D();
  // 指定渲染的场景
  view.scene = scene3D;
  // 指定使用的相机
  view.camera = camera;
  // 开始渲染
  Engine3D.startRenderView(view);
});

其他信息

添加关于bug的其他描述信息

X-OldGentleMan commented 1 year ago

这个是引擎的bug,下一个版本会修复