Skip to content

Commit d28240b

Browse files
committed
remove bufferattribute check in apply props
1 parent b247f95 commit d28240b

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

libs/core/src/lib/utils/apply-props.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BufferAttribute, Color, ColorManagement, Layers, RGBAFormat, Texture, UnsignedByteType } from 'three';
1+
import { Color, ColorManagement, Layers, RGBAFormat, Texture, UnsignedByteType } from 'three';
22
import { NgtInstanceNode, getLocalState, invalidateInstance } from '../instance';
33
import { NgtState } from '../store';
44
import { NgtAnyRecord } from '../types';
@@ -72,11 +72,7 @@ export function applyProps(instance: NgtInstanceNode, props: NgtAnyRecord) {
7272
value.constructor &&
7373
targetProp.constructor.name === value.constructor.name
7474
) {
75-
if (value instanceof BufferAttribute && !value.array) {
76-
currentInstance[key] = value;
77-
} else {
78-
targetProp['copy'](value);
79-
}
75+
targetProp['copy'](value);
8076
if (!ColorManagement && !rootState.linear && isColor) targetProp['convertSRGBToLinear']();
8177
} // if nothing else fits, just set the single value, ignore undefined
8278
else if (value !== undefined) {

libs/soba/src/performances/instances.stories.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
ChangeDetectionStrategy,
3-
Component,
4-
CUSTOM_ELEMENTS_SCHEMA,
5-
input,
6-
Signal,
7-
signal,
8-
viewChild,
9-
} from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, input, Signal, viewChild } from '@angular/core';
102
import { Meta } from '@storybook/angular';
113
import { injectBeforeRender, injectObjectEvents, omit, pick } from 'angular-three';
124
import { NgtsOrbitControls } from 'angular-three-soba/controls';
@@ -52,16 +44,20 @@ class Shoe {
5244
random = pick(this.data, 'random');
5345

5446
instance = viewChild.required(NgtsInstance);
55-
hovered = signal(false);
47+
48+
// NOTE: this can be just a property because we use it in the injectBeforeRender loop
49+
// and not bind in the template. If we were to bind it in the template, it would
50+
// have to be a signal
51+
hovered = false;
5652

5753
constructor() {
5854
injectObjectEvents(() => this.instance().positionMesh(), {
5955
pointerover: (event) => {
6056
event.stopPropagation();
61-
this.hovered.set(true);
57+
this.hovered = true;
6258
},
6359
pointerout: () => {
64-
this.hovered.set(false);
60+
this.hovered = false;
6561
},
6662
});
6763

@@ -76,8 +72,8 @@ class Shoe {
7672
instance.scale.x =
7773
instance.scale.y =
7874
instance.scale.z =
79-
MathUtils.lerp(instance.scale.z, this.hovered() ? 1.4 : 1, 0.1);
80-
instance.color.lerp(color.set(this.hovered() ? 'red' : 'white'), this.hovered() ? 1 : 0.1);
75+
MathUtils.lerp(instance.scale.z, this.hovered ? 1.4 : 1, 0.1);
76+
instance.color.lerp(color.set(this.hovered ? 'red' : 'white'), this.hovered ? 1 : 0.1);
8177
});
8278
}
8379
}
@@ -146,6 +142,6 @@ export const Default = makeStoryObject(DefaultInstancesStory, {
146142
camera: { position: [0, 0, 20], fov: 50 },
147143
},
148144
argsOptions: {
149-
range: number(100, { range: true, min: 0, max: 1000, step: 1 }),
145+
range: number(100, { range: true, min: 10, max: 500, step: 1 }),
150146
},
151147
});

0 commit comments

Comments
 (0)