Browse Source

fix(core): allow comments inside TresInstance

Madjid Taha 2 years ago
parent
commit
471c6f47d3

+ 1 - 0
packages/tres/src/components/TheBasic.vue

@@ -35,6 +35,7 @@ onLoop(({ elapsed }) => {
       <TresMesh ref="sphereRef" :position="[0, 4, 0]" cast-shadow>
         <TresSphereGeometry />
         <TresMeshToonMaterial color="#FBB03B" />
+        <!-- <TresMeshToonMaterial color="#FBB03B" /> -->
       </TresMesh>
       <TresDirectionalLight :position="[0, 8, 4]" :intensity="0.7" cast-shadow />
       <TresMesh :rotation="[-Math.PI / 2, 0, 0]" receive-shadow>

+ 2 - 1
packages/tres/src/core/useInstanceCreator/index.ts

@@ -159,10 +159,11 @@ export function useInstanceCreator(prefix: string) {
   function createInstanceFromVNode(vnode: TresVNode): TresInstance | TresInstance[] | undefined {
     const fragmentRegex = /^Symbol\(Fragment\)$/g
     const textRegex = /^Symbol\(Text\)$/g
+    const commentRegex = /^Symbol\(Comment\)$/g
     // Check if the vnode is a Fragment
     if (fragmentRegex.test(vnode.type.toString())) {
       return vnode.children.map(child => createInstanceFromVNode(child as TresVNode)) as TresInstance[]
-    } else if (textRegex.test(vnode.type.toString())) {
+    } else if (textRegex.test(vnode.type.toString()) || commentRegex.test(vnode.type.toString())) {
       return
     } else {
       const vNodeType = ((vnode.type as TresVNodeType).name as string).replace(prefix, '')