|
6 | 6 | euler,
|
7 | 7 | quaternion,
|
8 | 8 | boolean,
|
9 |
| - string, |
10 |
| -} from '../validators'; |
| 9 | + name, |
| 10 | +} from '../types'; |
| 11 | +import { nameValidator } from '../validators'; |
11 | 12 |
|
12 | 13 | /**
|
13 | 14 | * This is the base mixin component for most object components in VueGL,
|
@@ -37,7 +38,7 @@ export default {
|
37 | 38 | /** Whether the material receives shadows. */
|
38 | 39 | receiveShadow: boolean,
|
39 | 40 | /** Optional name of the object. */
|
40 |
| - name: string, |
| 41 | + name: { type: name, validator: nameValidator }, |
41 | 42 | /** Whether the object is visible. */
|
42 | 43 | hidden: boolean,
|
43 | 44 | },
|
@@ -93,15 +94,15 @@ export default {
|
93 | 94 | },
|
94 | 95 | parent(parent) { parent.add(this.inst); },
|
95 | 96 | name: [
|
96 |
| - function handler(name) { this.inst.name = name; }, |
| 97 | + function handler(newName) { this.inst.name = newName; }, |
97 | 98 | {
|
98 |
| - handler(name, oldName) { |
| 99 | + handler(newName, oldName) { |
99 | 100 | if (oldName !== undefined) {
|
100 | 101 | this.vglNamespace.object3ds.delete(oldName, this.inst);
|
101 |
| - if (name === undefined) this.vglObject3d.unlisten(this.emitAsObject3d); |
| 102 | + if (newName === undefined) this.vglObject3d.unlisten(this.emitAsObject3d); |
102 | 103 | }
|
103 |
| - if (name !== undefined) { |
104 |
| - this.vglNamespace.object3ds.set(name, this.inst); |
| 104 | + if (newName !== undefined) { |
| 105 | + this.vglNamespace.object3ds.set(newName, this.inst); |
105 | 106 | if (oldName === undefined) this.vglObject3d.listen(this.emitAsObject3d);
|
106 | 107 | }
|
107 | 108 | },
|
|
0 commit comments