nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: vue-gl/vue-gl
Pull request #556 (2019-06-03 08:34:00)

Named object3d
I realized that the object3d component doesn't apply the name props to the native ThreeJS Object3D (inst)
Having this name set is really convenient especially for Raytracing.

This PR basically apply the name on init and on change of the component prop 'name' to the inst object


Patch:
diff --git a/src/core/vgl-object3d.js b/src/core/vgl-object3d.js
index e42031e..00f03b7 100644
--- a/src/core/vgl-object3d.js
+++ b/src/core/vgl-object3d.js
@@ -76,7 +76,11 @@ export default {
           receiveShadow: this.receiveShadow,
           visible: this.visible,
         });
-        if (this.name !== undefined) this.vglNamespace.object3ds[this.name] = inst;
+        if (this.name !== undefined) {
+          // eslint-disable-next-line no-param-reassign
+          inst.name = this.name;
+          this.vglNamespace.object3ds[this.name] = inst;
+        }
       },
       immediate: true,
     },
@@ -92,6 +96,7 @@ export default {
     name(name, oldName) {
       const { vglNamespace: { object3ds }, inst } = this;
       if (object3ds[oldName] === inst) delete object3ds[oldName];
+      this.inst.name = name;
       object3ds[name] = inst;
     },
     visible(visible) { this.inst.visible = visible; },


Test patch:
diff --git a/test/core/vgl-object3d.spec.js b/test/core/vgl-object3d.spec.js
index 523122a..7fd4054 100644
--- a/test/core/vgl-object3d.spec.js
+++ b/test/core/vgl-object3d.spec.js
@@ -132,4 +132,14 @@ describe('VglObject3d', () => {
     child.$destroy();
     expect(vm.inst.children).not.toContain(child.inst);
   });
+  test('the instance should have the name applied on ThreeJS Object inst', () => {
+    const { inst } = new (Vue.extend(VglObject3d))({ inject, propsData: { name: 'test' } });
+    expect(inst.name).toBe('test');
+  });
+  test('the properties "name" of the instance should change after props change', async () => {
+    const vm = new (Vue.extend(VglObject3d))({ inject, propsData: { name: 'test' } });
+    vm.name = 'newName';
+    await vm.$nextTick();
+    expect(vm.inst.name).toBe('newName');
+  });
 });