From beee7b3d564e983e64b51bb4e97c6c357c6de89a Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Thu, 23 Mar 2023 18:25:03 +0100 Subject: [PATCH] feat: buffergeometry setAttribute logic --- playground/src/App.vue | 4 ++-- playground/src/components/TheParticles.vue | 17 +++++++---------- src/core/nodeOps.ts | 11 ++++++++++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/playground/src/App.vue b/playground/src/App.vue index 08e9b4d96..04275867b 100644 --- a/playground/src/App.vue +++ b/playground/src/App.vue @@ -1,8 +1,8 @@ diff --git a/playground/src/components/TheParticles.vue b/playground/src/components/TheParticles.vue index 989f320cb..ff4ff508c 100644 --- a/playground/src/components/TheParticles.vue +++ b/playground/src/components/TheParticles.vue @@ -1,16 +1,15 @@ diff --git a/src/core/nodeOps.ts b/src/core/nodeOps.ts index 45ef51c0d..1f1b71b7e 100644 --- a/src/core/nodeOps.ts +++ b/src/core/nodeOps.ts @@ -1,4 +1,4 @@ -import { Mesh } from 'three' +import { BufferAttribute, Mesh } from 'three' import { useCamera, useRaycaster, useRenderLoop, useLogger } from '/@/composables' import { RendererOptions } from 'vue' import { catalogue } from './catalogue' @@ -131,6 +131,15 @@ export const nodeOps: RendererOptions = { node.parent = scene as TresObject } + if(root.type === 'BufferGeometry') { + const chain = key.split('-') + key = chain.pop() as string + root.setAttribute( + kebabToCamel(key), + new BufferAttribute(...(nextValue as ConstructorParameters)) + ) + } + // Traverse pierced props (e.g. foo-bar=value => foo.bar = value) if (key.includes('-') && target === undefined) { const chain = key.split('-')