{"record":{"id":"62aeaa6fdd121e41","repo":"moeru-ai/airi","slug":"camera-or-renderer-initialisation-failure","errorCode":null,"errorMessage":"Camera or Renderer initialisation failure!","messagePattern":"Camera or Renderer initialisation failure!","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui-three/src/components/Controls/OrbitControls.vue","lineNumber":179,"sourceCode":"          x: camera.value.position.x,\n          y: camera.value.position.y,\n          z: camera.value.position.z,\n        },\n        newCameraDistance: controls.value.getDistance(),\n      },\n    )\n  }\n\n  disposeControlsChange?.()\n  controls.value?.addEventListener('change', onChange)\n  disposeControlsChange = () => controls.value?.removeEventListener('change', onChange)\n}\n\nonMounted(async () => {\n  // wait until camera is not undefined\n  await until(() => cameraTres.value && renderer.domElement).toBeTruthy()\n  if (!cameraTres.value || !renderer.domElement) {\n    console.warn('Camera or Renderer initialisation failure!')\n    return\n  }\n  // Narrow down the camera's type\n  if (!(cameraTres.value instanceof PerspectiveCamera)) {\n    console.warn('Camera is not perspective camera, type error!')\n    return\n  }\n  camera.value = cameraTres.value as PerspectiveCamera\n  // Obtain orbitControl instance\n  controls.value = new OrbitControls(camera.value, renderer.domElement)\n  controls.value.enablePan = false\n  controls.value.enableZoom = false\n  controls.value.enableRotate = false\n  // Align to tresjs conventions\n  controls.value.mouseButtons = {\n    LEFT: MOUSE.ROTATE,\n    MIDDLE: MOUSE.DOLLY,\n    RIGHT: MOUSE.PAN,","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui-three/src/components/Controls/OrbitControls.vue#L161-L197","documentation":"This Tres-based OrbitControls wrapper waits with VueUse until() for both a camera from the Tres context and renderer.domElement. If the wait ends while either is still missing (component torn down, or the refs never become truthy because there is no camera in the context), it warns and skips creating the controls entirely.","triggerScenarios":"Using OrbitControls outside a proper <TresCanvas> tree (no camera injected via the Tres camera context), a scene that never declares a camera, or the component being unmounted while the wait is pending so the refs stay undefined.","commonSituations":"Copy-pasting the controls into a plain three.js scene that is not a Tres context; camera registered after the controls in a way that never populates the context; HMR/unmount races during development.","solutions":["Ensure the controls are inside the same <TresCanvas> scene graph that owns the camera and renderer","Declare a camera in the scene (e.g. <TresPerspectiveCamera />) so the Tres camera context is populated before the controls mount","Mount the controls only once the canvas/camera exist (v-if or key on canvas readiness)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before mounting OrbitControls, ensure a camera exists in the Tres scene\nconst camera = useCamera()\nconst ready = computed(() => Boolean(camera?.camera))\n// template: <OrbitControls v-if=\"ready\" />","typeGuard":"function hasTresCamera(camera: unknown): camera is { camera: Camera } {\n  return Boolean(camera) && typeof camera === 'object' && 'camera' in (camera as object) && (camera as any).camera != null\n}","tryCatchPattern":null,"preventionTips":["Always place controls inside the <TresCanvas> tree that owns the camera and renderer","Declare a camera in the scene before the controls mount","Do not reuse the component outside a Tres context; plain three.js scenes should use OrbitControls from three directly"],"tags":["three","tresjs","orbit-controls","camera","initialization"],"backgroundTag":"missing-camera-reference","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}