Property 'rotateY' does not exist on type 'GameObject'

Hello! I’m following your simple use case example of adding a Rotate.ts script to a game object here. The generated C# file is getting created in Unity, and I’ve added the script to my game object. But it’s not rotating, and I’m seeing this error: Property 'rotateY' does not exist on type 'GameObject'.. Which when I print this, that is correct in saying the method rotateY does not exist, but I was wondering, if that’s not correct, is it possible these docs aren’t up to date? Or am I missing something else that makes this a rotate-able object?

Original Post on Discord

by user 690021744479830061

The error is not correct. Sometimes VSCode is confused or doesnt have all the info yet. Try to restart vscode

You can see the same here: StackBlitz

The error in VSCode comes in & out but the main issue is that the game object doesn’t seem to be rotating? When I look at this.gameObject in the console, I don’t see a rotateY method in there, so that might be why it’s not working?

by user 690021744479830061

Have a look at the prototype
image.png

it’s not on the mesh itself but the Object3D. Is it perhaps using instancing? (e.g. has the material gpu instancing enabled in Unity)

rotateY is a method by three.js

Ohh! I see

by user 690021744479830061

If you have instancing enabled try marking it dirty by calling the static method on InstanceUtil

So these are actually all just writing in Three.js?

by user 690021744479830061

InstanceUtil.markDirty i think

exactly

I started adding more docs about the last couple of days Scripting Introduction | Needle Engine Documentation

It’s basically three.js + integrations into Unity/Blender and a lot of other features :stuck_out_tongue:

So is there a place/way that I can actually inject some custom code on scene initialization? As opposed to adding code to a specific game object?

My goal right now is to add a GLB model into the Unity scene, but if I can do it more three.js-ey that would be ideal. So in Three.js I would just write something like:

const loader = new THREE.GLTFLoader()
const modelFile = './assets/mesh.glb'

loader.load(modelFile, (gltf) => {
   scene.add(gltf.scene)
})

Can something like that convert/display into the Unity scene?

by user 690021744479830061

that would basically be this part
image.png

There are some callbacks during initialization.

What do you mean by convert/display into the Unity scene?

You can download the glb and just add it to the scene in Unity too.

The recommended way (depending on what extensions your glb brings) would actually be by using our AssetReference type. e.g.

ContextRegistry.addContextCreatedCallback((args) => {
  const context = args.context as Context;

  const glbReference = AssetReference.getOrCreate("some_id", "the/url.glb", context);
  glbReference.instantiate(context.scene);
}