UNPKG

@threepipe/plugin-svg-renderer

Version:

Plugins for SVG Rendering of 3d objects for Threepipe

1 lines 1.76 MB
{"version":3,"file":"index.mjs","sources":["../../../node_modules/three/examples/jsm/renderers/Projector.js","../../../node_modules/three/examples/jsm/renderers/SVGRenderer.js","../../../node_modules/uiconfig.js/dist/index.js","../../../node_modules/ts-browser-helpers/dist/bundle.esm.js","../src/basic/BasicSVGRenderer.ts","../src/BasicSVGRendererPlugin.ts","../src/three-svg-renderer/core/viewmap/ViewEdge.ts","../src/three-svg-renderer/utils/buffergeometry.ts","../src/three-svg-renderer/utils/geometry.ts","../src/three-svg-renderer/utils/orientationtests.ts","../src/three-svg-renderer/core/viewmap/ViewVertex.ts","../src/three-svg-renderer/core/viewmap/Chain.ts","../src/three-svg-renderer/core/viewmap/Polygon.ts","../node_modules/arrangement-2d-js/build/Arrangement2D.esm.js","../src/three-svg-renderer/core/viewmap/operations/computePolygons.ts","../src/three-svg-renderer/core/viewmap/operations/createViewVertex.ts","../src/three-svg-renderer/core/viewmap/operations/setupEdges.ts","../src/three-svg-renderer/core/viewmap/operations/assignPolygons.ts","../src/three-svg-renderer/core/viewmap/operations/computeChainsVisibility.ts","../node_modules/fast-triangle-triangle-intersection/build/index.esm.js","../src/three-svg-renderer/core/viewmap/operations/meshIntersectionCb.ts","../src/three-svg-renderer/core/viewmap/operations/splitEdge.ts","../src/three-svg-renderer/core/viewmap/operations/computeMeshIntersections.ts","../src/three-svg-renderer/core/viewmap/operations/createChains.ts","../node_modules/isect/build/isect.module.js","../src/three-svg-renderer/core/viewmap/operations/find2dSingularities.ts","../src/three-svg-renderer/core/viewmap/operations/find3dSingularities.ts","../src/three-svg-renderer/core/viewmap/Viewmap.ts","../node_modules/@svgdotjs/svg.js/dist/svg.esm.js","../node_modules/@svgdotjs/svg.topath.js/src/svg.topath.js","../src/three-svg-renderer/core/svg/SVGDrawHandler.ts","../src/three-svg-renderer/core/svg/passes/DrawPass.ts","../src/three-svg-renderer/core/svg/svgutils.ts","../src/three-svg-renderer/utils/objects.ts","../src/three-svg-renderer/core/svg/passes/FillPass.ts","../src/three-svg-renderer/core/svg/passes/SingularityPointPass.ts","../src/three-svg-renderer/core/svg/passes/ChainPass.ts","../src/three-mesh-halfedge/utils/geometry.ts","../src/three-mesh-halfedge/core/Halfedge.ts","../src/three-mesh-halfedge/operations/addEdge.ts","../src/three-mesh-halfedge/core/Face.ts","../src/three-mesh-halfedge/operations/addFace.ts","../src/three-mesh-halfedge/core/Vertex.ts","../src/three-mesh-halfedge/operations/addVertex.ts","../src/three-mesh-halfedge/operations/removeFace.ts","../src/three-mesh-halfedge/operations/removeEdge.ts","../src/three-mesh-halfedge/operations/removeVertex.ts","../src/three-mesh-halfedge/operations/cutFace.ts","../src/three-mesh-halfedge/operations/splitEdge.ts","../src/three-mesh-halfedge/operations/setFromGeometry.ts","../src/three-mesh-halfedge/core/HalfedgeDS.ts","../src/three-mesh-halfedge/augments.ts","../node_modules/three-mesh-bvh/src/core/Constants.js","../node_modules/three-mesh-bvh/src/core/build/geometryUtils.js","../node_modules/three-mesh-bvh/src/core/build/computeBoundsUtils.js","../node_modules/three-mesh-bvh/src/utils/ArrayBoxUtilities.js","../node_modules/three-mesh-bvh/src/core/build/splitUtils.js","../node_modules/three-mesh-bvh/src/core/MeshBVHNode.js","../node_modules/three-mesh-bvh/src/core/build/sortUtils.generated.js","../node_modules/three-mesh-bvh/src/core/build/sortUtils_indirect.generated.js","../node_modules/three-mesh-bvh/src/core/utils/nodeBufferUtils.js","../node_modules/three-mesh-bvh/src/core/build/buildUtils.js","../node_modules/three-mesh-bvh/src/core/build/buildTree.js","../node_modules/three-mesh-bvh/src/math/SeparatingAxisBounds.js","../node_modules/three-mesh-bvh/src/math/MathUtilities.js","../node_modules/three-mesh-bvh/src/math/ExtendedTriangle.js","../node_modules/three-mesh-bvh/src/math/OrientedBox.js","../node_modules/three-mesh-bvh/src/utils/PrimitivePool.js","../node_modules/three-mesh-bvh/src/utils/ExtendedTrianglePool.js","../node_modules/three-mesh-bvh/src/core/utils/BufferStack.js","../node_modules/three-mesh-bvh/src/core/cast/shapecast.js","../node_modules/three-mesh-bvh/src/core/cast/closestPointToPoint.js","../node_modules/three-mesh-bvh/src/utils/ThreeRayIntersectUtilities.js","../node_modules/three-mesh-bvh/src/utils/TriangleUtilities.js","../node_modules/three-mesh-bvh/src/core/utils/iterationUtils.generated.js","../node_modules/three-mesh-bvh/src/core/cast/refit.generated.js","../node_modules/three-mesh-bvh/src/core/utils/intersectUtils.js","../node_modules/three-mesh-bvh/src/core/utils/iterationUtils_indirect.generated.js","../node_modules/three-mesh-bvh/src/core/cast/raycast.generated.js","../node_modules/three-mesh-bvh/src/core/cast/raycastFirst.generated.js","../node_modules/three-mesh-bvh/src/core/cast/intersectsGeometry.generated.js","../node_modules/three-mesh-bvh/src/core/cast/closestPointToGeometry.generated.js","../node_modules/three-mesh-bvh/src/core/cast/refit_indirect.generated.js","../node_modules/three-mesh-bvh/src/core/cast/raycast_indirect.generated.js","../node_modules/three-mesh-bvh/src/core/cast/raycastFirst_indirect.generated.js","../node_modules/three-mesh-bvh/src/core/cast/intersectsGeometry_indirect.generated.js","../node_modules/three-mesh-bvh/src/core/cast/closestPointToGeometry_indirect.generated.js","../node_modules/three-mesh-bvh/src/utils/BufferUtils.js","../node_modules/three-mesh-bvh/src/core/cast/bvhcast.js","../node_modules/three-mesh-bvh/src/core/MeshBVH.js","../node_modules/three-mesh-bvh/src/utils/GeometryRayIntersectUtilities.js","../node_modules/three-mesh-bvh/src/utils/ExtensionUtilities.js","../src/three-svg-renderer/core/SVGMesh.ts","../src/three-svg-renderer/SVGRenderer.ts","../src/ThreeSVGRendererPlugin.ts"],"sourcesContent":["import {\n\tBox3,\n\tColor,\n\tDoubleSide,\n\tFrustum,\n\tMatrix3,\n\tMatrix4,\n\tVector2,\n\tVector3,\n\tVector4\n} from 'three';\n\nclass RenderableObject {\n\n\tconstructor() {\n\n\t\tthis.id = 0;\n\n\t\tthis.object = null;\n\t\tthis.z = 0;\n\t\tthis.renderOrder = 0;\n\n\t}\n\n}\n\n//\n\nclass RenderableFace {\n\n\tconstructor() {\n\n\t\tthis.id = 0;\n\n\t\tthis.v1 = new RenderableVertex();\n\t\tthis.v2 = new RenderableVertex();\n\t\tthis.v3 = new RenderableVertex();\n\n\t\tthis.normalModel = new Vector3();\n\n\t\tthis.vertexNormalsModel = [ new Vector3(), new Vector3(), new Vector3() ];\n\t\tthis.vertexNormalsLength = 0;\n\n\t\tthis.color = new Color();\n\t\tthis.material = null;\n\t\tthis.uvs = [ new Vector2(), new Vector2(), new Vector2() ];\n\n\t\tthis.z = 0;\n\t\tthis.renderOrder = 0;\n\n\t}\n\n}\n\n//\n\nclass RenderableVertex {\n\n\tconstructor() {\n\n\t\tthis.position = new Vector3();\n\t\tthis.positionWorld = new Vector3();\n\t\tthis.positionScreen = new Vector4();\n\n\t\tthis.visible = true;\n\n\t}\n\n\tcopy( vertex ) {\n\n\t\tthis.positionWorld.copy( vertex.positionWorld );\n\t\tthis.positionScreen.copy( vertex.positionScreen );\n\n\t}\n\n}\n\n//\n\nclass RenderableLine {\n\n\tconstructor() {\n\n\t\tthis.id = 0;\n\n\t\tthis.v1 = new RenderableVertex();\n\t\tthis.v2 = new RenderableVertex();\n\n\t\tthis.vertexColors = [ new Color(), new Color() ];\n\t\tthis.material = null;\n\n\t\tthis.z = 0;\n\t\tthis.renderOrder = 0;\n\n\t}\n\n}\n\n//\n\nclass RenderableSprite {\n\n\tconstructor() {\n\n\t\tthis.id = 0;\n\n\t\tthis.object = null;\n\n\t\tthis.x = 0;\n\t\tthis.y = 0;\n\t\tthis.z = 0;\n\n\t\tthis.rotation = 0;\n\t\tthis.scale = new Vector2();\n\n\t\tthis.material = null;\n\t\tthis.renderOrder = 0;\n\n\t}\n\n}\n\n//\n\nclass Projector {\n\n\tconstructor() {\n\n\t\tlet _object, _objectCount, _objectPoolLength = 0,\n\t\t\t_vertex, _vertexCount, _vertexPoolLength = 0,\n\t\t\t_face, _faceCount, _facePoolLength = 0,\n\t\t\t_line, _lineCount, _linePoolLength = 0,\n\t\t\t_sprite, _spriteCount, _spritePoolLength = 0,\n\t\t\t_modelMatrix;\n\n\t\tconst\n\n\t\t\t_renderData = { objects: [], lights: [], elements: [] },\n\n\t\t\t_vector3 = new Vector3(),\n\t\t\t_vector4 = new Vector4(),\n\n\t\t\t_clipBox = new Box3( new Vector3( - 1, - 1, - 1 ), new Vector3( 1, 1, 1 ) ),\n\t\t\t_boundingBox = new Box3(),\n\t\t\t_points3 = new Array( 3 ),\n\n\t\t\t_viewMatrix = new Matrix4(),\n\t\t\t_viewProjectionMatrix = new Matrix4(),\n\n\t\t\t_modelViewProjectionMatrix = new Matrix4(),\n\n\t\t\t_frustum = new Frustum(),\n\n\t\t\t_objectPool = [], _vertexPool = [], _facePool = [], _linePool = [], _spritePool = [];\n\n\t\t//\n\n\t\tfunction RenderList() {\n\n\t\t\tconst normals = [];\n\t\t\tconst colors = [];\n\t\t\tconst uvs = [];\n\n\t\t\tlet object = null;\n\n\t\t\tconst normalMatrix = new Matrix3();\n\n\t\t\tfunction setObject( value ) {\n\n\t\t\t\tobject = value;\n\n\t\t\t\tnormalMatrix.getNormalMatrix( object.matrixWorld );\n\n\t\t\t\tnormals.length = 0;\n\t\t\t\tcolors.length = 0;\n\t\t\t\tuvs.length = 0;\n\n\t\t\t}\n\n\t\t\tfunction projectVertex( vertex ) {\n\n\t\t\t\tconst position = vertex.position;\n\t\t\t\tconst positionWorld = vertex.positionWorld;\n\t\t\t\tconst positionScreen = vertex.positionScreen;\n\n\t\t\t\tpositionWorld.copy( position ).applyMatrix4( _modelMatrix );\n\t\t\t\tpositionScreen.copy( positionWorld ).applyMatrix4( _viewProjectionMatrix );\n\n\t\t\t\tconst invW = 1 / positionScreen.w;\n\n\t\t\t\tpositionScreen.x *= invW;\n\t\t\t\tpositionScreen.y *= invW;\n\t\t\t\tpositionScreen.z *= invW;\n\n\t\t\t\tvertex.visible = positionScreen.x >= - 1 && positionScreen.x <= 1 &&\n\t\t\t\t\t\t positionScreen.y >= - 1 && positionScreen.y <= 1 &&\n\t\t\t\t\t\t positionScreen.z >= - 1 && positionScreen.z <= 1;\n\n\t\t\t}\n\n\t\t\tfunction pushVertex( x, y, z ) {\n\n\t\t\t\t_vertex = getNextVertexInPool();\n\t\t\t\t_vertex.position.set( x, y, z );\n\n\t\t\t\tprojectVertex( _vertex );\n\n\t\t\t}\n\n\t\t\tfunction pushNormal( x, y, z ) {\n\n\t\t\t\tnormals.push( x, y, z );\n\n\t\t\t}\n\n\t\t\tfunction pushColor( r, g, b ) {\n\n\t\t\t\tcolors.push( r, g, b );\n\n\t\t\t}\n\n\t\t\tfunction pushUv( x, y ) {\n\n\t\t\t\tuvs.push( x, y );\n\n\t\t\t}\n\n\t\t\tfunction checkTriangleVisibility( v1, v2, v3 ) {\n\n\t\t\t\tif ( v1.visible === true || v2.visible === true || v3.visible === true ) return true;\n\n\t\t\t\t_points3[ 0 ] = v1.positionScreen;\n\t\t\t\t_points3[ 1 ] = v2.positionScreen;\n\t\t\t\t_points3[ 2 ] = v3.positionScreen;\n\n\t\t\t\treturn _clipBox.intersectsBox( _boundingBox.setFromPoints( _points3 ) );\n\n\t\t\t}\n\n\t\t\tfunction checkBackfaceCulling( v1, v2, v3 ) {\n\n\t\t\t\treturn ( ( v3.positionScreen.x - v1.positionScreen.x ) *\n\t\t\t\t\t ( v2.positionScreen.y - v1.positionScreen.y ) -\n\t\t\t\t\t ( v3.positionScreen.y - v1.positionScreen.y ) *\n\t\t\t\t\t ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;\n\n\t\t\t}\n\n\t\t\tfunction pushLine( a, b ) {\n\n\t\t\t\tconst v1 = _vertexPool[ a ];\n\t\t\t\tconst v2 = _vertexPool[ b ];\n\n\t\t\t\t// Clip\n\n\t\t\t\tv1.positionScreen.copy( v1.position ).applyMatrix4( _modelViewProjectionMatrix );\n\t\t\t\tv2.positionScreen.copy( v2.position ).applyMatrix4( _modelViewProjectionMatrix );\n\n\t\t\t\tif ( clipLine( v1.positionScreen, v2.positionScreen ) === true ) {\n\n\t\t\t\t\t// Perform the perspective divide\n\t\t\t\t\tv1.positionScreen.multiplyScalar( 1 / v1.positionScreen.w );\n\t\t\t\t\tv2.positionScreen.multiplyScalar( 1 / v2.positionScreen.w );\n\n\t\t\t\t\t_line = getNextLineInPool();\n\t\t\t\t\t_line.id = object.id;\n\t\t\t\t\t_line.v1.copy( v1 );\n\t\t\t\t\t_line.v2.copy( v2 );\n\t\t\t\t\t_line.z = Math.max( v1.positionScreen.z, v2.positionScreen.z );\n\t\t\t\t\t_line.renderOrder = object.renderOrder;\n\n\t\t\t\t\t_line.material = object.material;\n\n\t\t\t\t\tif ( object.material.vertexColors ) {\n\n\t\t\t\t\t\t_line.vertexColors[ 0 ].fromArray( colors, a * 3 );\n\t\t\t\t\t\t_line.vertexColors[ 1 ].fromArray( colors, b * 3 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_renderData.elements.push( _line );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tfunction pushTriangle( a, b, c, material ) {\n\n\t\t\t\tconst v1 = _vertexPool[ a ];\n\t\t\t\tconst v2 = _vertexPool[ b ];\n\t\t\t\tconst v3 = _vertexPool[ c ];\n\n\t\t\t\tif ( checkTriangleVisibility( v1, v2, v3 ) === false ) return;\n\n\t\t\t\tif ( material.side === DoubleSide || checkBackfaceCulling( v1, v2, v3 ) === true ) {\n\n\t\t\t\t\t_face = getNextFaceInPool();\n\n\t\t\t\t\t_face.id = object.id;\n\t\t\t\t\t_face.v1.copy( v1 );\n\t\t\t\t\t_face.v2.copy( v2 );\n\t\t\t\t\t_face.v3.copy( v3 );\n\t\t\t\t\t_face.z = ( v1.positionScreen.z + v2.positionScreen.z + v3.positionScreen.z ) / 3;\n\t\t\t\t\t_face.renderOrder = object.renderOrder;\n\n\t\t\t\t\t// face normal\n\t\t\t\t\t_vector3.subVectors( v3.position, v2.position );\n\t\t\t\t\t_vector4.subVectors( v1.position, v2.position );\n\t\t\t\t\t_vector3.cross( _vector4 );\n\t\t\t\t\t_face.normalModel.copy( _vector3 );\n\t\t\t\t\t_face.normalModel.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t\tfor ( let i = 0; i < 3; i ++ ) {\n\n\t\t\t\t\t\tconst normal = _face.vertexNormalsModel[ i ];\n\t\t\t\t\t\tnormal.fromArray( normals, arguments[ i ] * 3 );\n\t\t\t\t\t\tnormal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t\t\tconst uv = _face.uvs[ i ];\n\t\t\t\t\t\tuv.fromArray( uvs, arguments[ i ] * 2 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_face.vertexNormalsLength = 3;\n\n\t\t\t\t\t_face.material = material;\n\n\t\t\t\t\tif ( material.vertexColors ) {\n\n\t\t\t\t\t\t_face.color.fromArray( colors, a * 3 );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_renderData.elements.push( _face );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsetObject: setObject,\n\t\t\t\tprojectVertex: projectVertex,\n\t\t\t\tcheckTriangleVisibility: checkTriangleVisibility,\n\t\t\t\tcheckBackfaceCulling: checkBackfaceCulling,\n\t\t\t\tpushVertex: pushVertex,\n\t\t\t\tpushNormal: pushNormal,\n\t\t\t\tpushColor: pushColor,\n\t\t\t\tpushUv: pushUv,\n\t\t\t\tpushLine: pushLine,\n\t\t\t\tpushTriangle: pushTriangle\n\t\t\t};\n\n\t\t}\n\n\t\tconst renderList = new RenderList();\n\n\t\tfunction projectObject( object ) {\n\n\t\t\tif ( object.visible === false ) return;\n\n\t\t\tif ( object.isLight ) {\n\n\t\t\t\t_renderData.lights.push( object );\n\n\t\t\t} else if ( object.isMesh || object.isLine || object.isPoints ) {\n\n\t\t\t\tif ( object.material.visible === false ) return;\n\t\t\t\tif ( object.frustumCulled === true && _frustum.intersectsObject( object ) === false ) return;\n\n\t\t\t\taddObject( object );\n\n\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\tif ( object.material.visible === false ) return;\n\t\t\t\tif ( object.frustumCulled === true && _frustum.intersectsSprite( object ) === false ) return;\n\n\t\t\t\taddObject( object );\n\n\t\t\t}\n\n\t\t\tconst children = object.children;\n\n\t\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tprojectObject( children[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction addObject( object ) {\n\n\t\t\t_object = getNextObjectInPool();\n\t\t\t_object.id = object.id;\n\t\t\t_object.object = object;\n\n\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld );\n\t\t\t_vector3.applyMatrix4( _viewProjectionMatrix );\n\t\t\t_object.z = _vector3.z;\n\t\t\t_object.renderOrder = object.renderOrder;\n\n\t\t\t_renderData.objects.push( _object );\n\n\t\t}\n\n\t\tthis.projectScene = function ( scene, camera, sortObjects, sortElements ) {\n\n\t\t\t_faceCount = 0;\n\t\t\t_lineCount = 0;\n\t\t\t_spriteCount = 0;\n\n\t\t\t_renderData.elements.length = 0;\n\n\t\t\tif ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();\n\t\t\tif ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();\n\n\t\t\t_viewMatrix.copy( camera.matrixWorldInverse );\n\t\t\t_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );\n\n\t\t\t_frustum.setFromProjectionMatrix( _viewProjectionMatrix );\n\n\t\t\t//\n\n\t\t\t_objectCount = 0;\n\n\t\t\t_renderData.objects.length = 0;\n\t\t\t_renderData.lights.length = 0;\n\n\t\t\tprojectObject( scene );\n\n\t\t\tif ( sortObjects === true ) {\n\n\t\t\t\t_renderData.objects.sort( painterSort );\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tconst objects = _renderData.objects;\n\n\t\t\tfor ( let o = 0, ol = objects.length; o < ol; o ++ ) {\n\n\t\t\t\tconst object = objects[ o ].object;\n\t\t\t\tconst geometry = object.geometry;\n\n\t\t\t\trenderList.setObject( object );\n\n\t\t\t\t_modelMatrix = object.matrixWorld;\n\n\t\t\t\t_vertexCount = 0;\n\n\t\t\t\tif ( object.isMesh ) {\n\n\t\t\t\t\tlet material = object.material;\n\n\t\t\t\t\tconst isMultiMaterial = Array.isArray( material );\n\n\t\t\t\t\tconst attributes = geometry.attributes;\n\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\tif ( attributes.position === undefined ) continue;\n\n\t\t\t\t\tconst positions = attributes.position.array;\n\n\t\t\t\t\tfor ( let i = 0, l = positions.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\tlet x = positions[ i ];\n\t\t\t\t\t\tlet y = positions[ i + 1 ];\n\t\t\t\t\t\tlet z = positions[ i + 2 ];\n\n\t\t\t\t\t\tconst morphTargets = geometry.morphAttributes.position;\n\n\t\t\t\t\t\tif ( morphTargets !== undefined ) {\n\n\t\t\t\t\t\t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\t\t\t\t\t\t\tconst morphInfluences = object.morphTargetInfluences;\n\n\t\t\t\t\t\t\tfor ( let t = 0, tl = morphTargets.length; t < tl; t ++ ) {\n\n\t\t\t\t\t\t\t\tconst influence = morphInfluences[ t ];\n\n\t\t\t\t\t\t\t\tif ( influence === 0 ) continue;\n\n\t\t\t\t\t\t\t\tconst target = morphTargets[ t ];\n\n\t\t\t\t\t\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t\t\t\t\t\tx += target.getX( i / 3 ) * influence;\n\t\t\t\t\t\t\t\t\ty += target.getY( i / 3 ) * influence;\n\t\t\t\t\t\t\t\t\tz += target.getZ( i / 3 ) * influence;\n\n\t\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t\tx += ( target.getX( i / 3 ) - positions[ i ] ) * influence;\n\t\t\t\t\t\t\t\t\ty += ( target.getY( i / 3 ) - positions[ i + 1 ] ) * influence;\n\t\t\t\t\t\t\t\t\tz += ( target.getZ( i / 3 ) - positions[ i + 2 ] ) * influence;\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\trenderList.pushVertex( x, y, z );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( attributes.normal !== undefined ) {\n\n\t\t\t\t\t\tconst normals = attributes.normal.array;\n\n\t\t\t\t\t\tfor ( let i = 0, l = normals.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\trenderList.pushNormal( normals[ i ], normals[ i + 1 ], normals[ i + 2 ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( attributes.color !== undefined ) {\n\n\t\t\t\t\t\tconst colors = attributes.color.array;\n\n\t\t\t\t\t\tfor ( let i = 0, l = colors.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\trenderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( attributes.uv !== undefined ) {\n\n\t\t\t\t\t\tconst uvs = attributes.uv.array;\n\n\t\t\t\t\t\tfor ( let i = 0, l = uvs.length; i < l; i += 2 ) {\n\n\t\t\t\t\t\t\trenderList.pushUv( uvs[ i ], uvs[ i + 1 ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( geometry.index !== null ) {\n\n\t\t\t\t\t\tconst indices = geometry.index.array;\n\n\t\t\t\t\t\tif ( groups.length > 0 ) {\n\n\t\t\t\t\t\t\tfor ( let g = 0; g < groups.length; g ++ ) {\n\n\t\t\t\t\t\t\t\tconst group = groups[ g ];\n\n\t\t\t\t\t\t\t\tmaterial = isMultiMaterial === true\n\t\t\t\t\t\t\t\t\t ? object.material[ group.materialIndex ]\n\t\t\t\t\t\t\t\t\t : object.material;\n\n\t\t\t\t\t\t\t\tif ( material === undefined ) continue;\n\n\t\t\t\t\t\t\t\tfor ( let i = group.start, l = group.start + group.count; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\t\t\trenderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tfor ( let i = 0, l = indices.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\t\trenderList.pushTriangle( indices[ i ], indices[ i + 1 ], indices[ i + 2 ], material );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( groups.length > 0 ) {\n\n\t\t\t\t\t\t\tfor ( let g = 0; g < groups.length; g ++ ) {\n\n\t\t\t\t\t\t\t\tconst group = groups[ g ];\n\n\t\t\t\t\t\t\t\tmaterial = isMultiMaterial === true\n\t\t\t\t\t\t\t\t\t ? object.material[ group.materialIndex ]\n\t\t\t\t\t\t\t\t\t : object.material;\n\n\t\t\t\t\t\t\t\tif ( material === undefined ) continue;\n\n\t\t\t\t\t\t\t\tfor ( let i = group.start, l = group.start + group.count; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\t\t\trenderList.pushTriangle( i, i + 1, i + 2, material );\n\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tfor ( let i = 0, l = positions.length / 3; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\t\trenderList.pushTriangle( i, i + 1, i + 2, material );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( object.isLine ) {\n\n\t\t\t\t\t_modelViewProjectionMatrix.multiplyMatrices( _viewProjectionMatrix, _modelMatrix );\n\n\t\t\t\t\tconst attributes = geometry.attributes;\n\n\t\t\t\t\tif ( attributes.position !== undefined ) {\n\n\t\t\t\t\t\tconst positions = attributes.position.array;\n\n\t\t\t\t\t\tfor ( let i = 0, l = positions.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\trenderList.pushVertex( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( attributes.color !== undefined ) {\n\n\t\t\t\t\t\t\tconst colors = attributes.color.array;\n\n\t\t\t\t\t\t\tfor ( let i = 0, l = colors.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\t\trenderList.pushColor( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( geometry.index !== null ) {\n\n\t\t\t\t\t\t\tconst indices = geometry.index.array;\n\n\t\t\t\t\t\t\tfor ( let i = 0, l = indices.length; i < l; i += 2 ) {\n\n\t\t\t\t\t\t\t\trenderList.pushLine( indices[ i ], indices[ i + 1 ] );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tconst step = object.isLineSegments ? 2 : 1;\n\n\t\t\t\t\t\t\tfor ( let i = 0, l = ( positions.length / 3 ) - 1; i < l; i += step ) {\n\n\t\t\t\t\t\t\t\trenderList.pushLine( i, i + 1 );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( object.isPoints ) {\n\n\t\t\t\t\t_modelViewProjectionMatrix.multiplyMatrices( _viewProjectionMatrix, _modelMatrix );\n\n\t\t\t\t\tconst attributes = geometry.attributes;\n\n\t\t\t\t\tif ( attributes.position !== undefined ) {\n\n\t\t\t\t\t\tconst positions = attributes.position.array;\n\n\t\t\t\t\t\tfor ( let i = 0, l = positions.length; i < l; i += 3 ) {\n\n\t\t\t\t\t\t\t_vector4.set( positions[ i ], positions[ i + 1 ], positions[ i + 2 ], 1 );\n\t\t\t\t\t\t\t_vector4.applyMatrix4( _modelViewProjectionMatrix );\n\n\t\t\t\t\t\t\tpushPoint( _vector4, object, camera );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\t\tobject.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );\n\t\t\t\t\t_vector4.set( _modelMatrix.elements[ 12 ], _modelMatrix.elements[ 13 ], _modelMatrix.elements[ 14 ], 1 );\n\t\t\t\t\t_vector4.applyMatrix4( _viewProjectionMatrix );\n\n\t\t\t\t\tpushPoint( _vector4, object, camera );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( sortElements === true ) {\n\n\t\t\t\t_renderData.elements.sort( painterSort );\n\n\t\t\t}\n\n\t\t\treturn _renderData;\n\n\t\t};\n\n\t\tfunction pushPoint( _vector4, object, camera ) {\n\n\t\t\tconst invW = 1 / _vector4.w;\n\n\t\t\t_vector4.z *= invW;\n\n\t\t\tif ( _vector4.z >= - 1 && _vector4.z <= 1 ) {\n\n\t\t\t\t_sprite = getNextSpriteInPool();\n\t\t\t\t_sprite.id = object.id;\n\t\t\t\t_sprite.x = _vector4.x * invW;\n\t\t\t\t_sprite.y = _vector4.y * invW;\n\t\t\t\t_sprite.z = _vector4.z;\n\t\t\t\t_sprite.renderOrder = object.renderOrder;\n\t\t\t\t_sprite.object = object;\n\n\t\t\t\t_sprite.rotation = object.rotation;\n\n\t\t\t\t_sprite.scale.x = object.scale.x * Math.abs( _sprite.x - ( _vector4.x + camera.projectionMatrix.elements[ 0 ] ) / ( _vector4.w + camera.projectionMatrix.elements[ 12 ] ) );\n\t\t\t\t_sprite.scale.y = object.scale.y * Math.abs( _sprite.y - ( _vector4.y + camera.projectionMatrix.elements[ 5 ] ) / ( _vector4.w + camera.projectionMatrix.elements[ 13 ] ) );\n\n\t\t\t\t_sprite.material = object.material;\n\n\t\t\t\t_renderData.elements.push( _sprite );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Pools\n\n\t\tfunction getNextObjectInPool() {\n\n\t\t\tif ( _objectCount === _objectPoolLength ) {\n\n\t\t\t\tconst object = new RenderableObject();\n\t\t\t\t_objectPool.push( object );\n\t\t\t\t_objectPoolLength ++;\n\t\t\t\t_objectCount ++;\n\t\t\t\treturn object;\n\n\t\t\t}\n\n\t\t\treturn _objectPool[ _objectCount ++ ];\n\n\t\t}\n\n\t\tfunction getNextVertexInPool() {\n\n\t\t\tif ( _vertexCount === _vertexPoolLength ) {\n\n\t\t\t\tconst vertex = new RenderableVertex();\n\t\t\t\t_vertexPool.push( vertex );\n\t\t\t\t_vertexPoolLength ++;\n\t\t\t\t_vertexCount ++;\n\t\t\t\treturn vertex;\n\n\t\t\t}\n\n\t\t\treturn _vertexPool[ _vertexCount ++ ];\n\n\t\t}\n\n\t\tfunction getNextFaceInPool() {\n\n\t\t\tif ( _faceCount === _facePoolLength ) {\n\n\t\t\t\tconst face = new RenderableFace();\n\t\t\t\t_facePool.push( face );\n\t\t\t\t_facePoolLength ++;\n\t\t\t\t_faceCount ++;\n\t\t\t\treturn face;\n\n\t\t\t}\n\n\t\t\treturn _facePool[ _faceCount ++ ];\n\n\n\t\t}\n\n\t\tfunction getNextLineInPool() {\n\n\t\t\tif ( _lineCount === _linePoolLength ) {\n\n\t\t\t\tconst line = new RenderableLine();\n\t\t\t\t_linePool.push( line );\n\t\t\t\t_linePoolLength ++;\n\t\t\t\t_lineCount ++;\n\t\t\t\treturn line;\n\n\t\t\t}\n\n\t\t\treturn _linePool[ _lineCount ++ ];\n\n\t\t}\n\n\t\tfunction getNextSpriteInPool() {\n\n\t\t\tif ( _spriteCount === _spritePoolLength ) {\n\n\t\t\t\tconst sprite = new RenderableSprite();\n\t\t\t\t_spritePool.push( sprite );\n\t\t\t\t_spritePoolLength ++;\n\t\t\t\t_spriteCount ++;\n\t\t\t\treturn sprite;\n\n\t\t\t}\n\n\t\t\treturn _spritePool[ _spriteCount ++ ];\n\n\t\t}\n\n\t\t//\n\n\t\tfunction painterSort( a, b ) {\n\n\t\t\tif ( a.renderOrder !== b.renderOrder ) {\n\n\t\t\t\treturn a.renderOrder - b.renderOrder;\n\n\t\t\t} else if ( a.z !== b.z ) {\n\n\t\t\t\treturn b.z - a.z;\n\n\t\t\t} else if ( a.id !== b.id ) {\n\n\t\t\t\treturn a.id - b.id;\n\n\t\t\t} else {\n\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction clipLine( s1, s2 ) {\n\n\t\t\tlet alpha1 = 0, alpha2 = 1;\n\n\t\t\t// Calculate the boundary coordinate of each vertex for the near and far clip planes,\n\t\t\t// Z = -1 and Z = +1, respectively.\n\n\t\t\tconst bc1near = s1.z + s1.w,\n\t\t\t\tbc2near = s2.z + s2.w,\n\t\t\t\tbc1far = - s1.z + s1.w,\n\t\t\t\tbc2far = - s2.z + s2.w;\n\n\t\t\tif ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) {\n\n\t\t\t\t// Both vertices lie entirely within all clip planes.\n\t\t\t\treturn true;\n\n\t\t\t} else if ( ( bc1near < 0 && bc2near < 0 ) || ( bc1far < 0 && bc2far < 0 ) ) {\n\n\t\t\t\t// Both vertices lie entirely outside one of the clip planes.\n\t\t\t\treturn false;\n\n\t\t\t} else {\n\n\t\t\t\t// The line segment spans at least one clip plane.\n\n\t\t\t\tif ( bc1near < 0 ) {\n\n\t\t\t\t\t// v1 lies outside the near plane, v2 inside\n\t\t\t\t\talpha1 = Math.max( alpha1, bc1near / ( bc1near - bc2near ) );\n\n\t\t\t\t} else if ( bc2near < 0 ) {\n\n\t\t\t\t\t// v2 lies outside the near plane, v1 inside\n\t\t\t\t\talpha2 = Math.min( alpha2, bc1near / ( bc1near - bc2near ) );\n\n\t\t\t\t}\n\n\t\t\t\tif ( bc1far < 0 ) {\n\n\t\t\t\t\t// v1 lies outside the far plane, v2 inside\n\t\t\t\t\talpha1 = Math.max( alpha1, bc1far / ( bc1far - bc2far ) );\n\n\t\t\t\t} else if ( bc2far < 0 ) {\n\n\t\t\t\t\t// v2 lies outside the far plane, v2 inside\n\t\t\t\t\talpha2 = Math.min( alpha2, bc1far / ( bc1far - bc2far ) );\n\n\t\t\t\t}\n\n\t\t\t\tif ( alpha2 < alpha1 ) {\n\n\t\t\t\t\t// The line segment spans two boundaries, but is outside both of them.\n\t\t\t\t\t// (This can't happen when we're only clipping against just near/far but good\n\t\t\t\t\t// to leave the check here for future usage if other clip planes are added.)\n\t\t\t\t\treturn false;\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// Update the s1 and s2 vertices to match the clipped line segment.\n\t\t\t\t\ts1.lerp( s2, alpha1 );\n\t\t\t\t\ts2.lerp( s1, 1 - alpha2 );\n\n\t\t\t\t\treturn true;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n}\n\nexport { RenderableObject, RenderableFace, RenderableVertex, RenderableLine, RenderableSprite, Projector };\n","import {\n\tBox2,\n\tCamera,\n\tColor,\n\tMatrix3,\n\tMatrix4,\n\tObject3D,\n\tVector3\n} from 'three';\nimport { Projector } from '../renderers/Projector.js';\nimport { RenderableFace } from '../renderers/Projector.js';\nimport { RenderableLine } from '../renderers/Projector.js';\nimport { RenderableSprite } from '../renderers/Projector.js';\n\nclass SVGObject extends Object3D {\n\n\tconstructor( node ) {\n\n\t\tsuper();\n\n\t\tthis.isSVGObject = true;\n\n\t\tthis.node = node;\n\n\t}\n\n}\n\nclass SVGRenderer {\n\n\tconstructor() {\n\n\t\tlet _renderData, _elements, _lights,\n\t\t\t_svgWidth, _svgHeight, _svgWidthHalf, _svgHeightHalf,\n\n\t\t\t_v1, _v2, _v3,\n\n\t\t\t_svgNode,\n\t\t\t_pathCount = 0,\n\n\t\t\t_precision = null,\n\t\t\t_quality = 1,\n\n\t\t\t_currentPath, _currentStyle;\n\n\t\tconst _this = this,\n\t\t\t_clipBox = new Box2(),\n\t\t\t_elemBox = new Box2(),\n\n\t\t\t_color = new Color(),\n\t\t\t_diffuseColor = new Color(),\n\t\t\t_ambientLight = new Color(),\n\t\t\t_directionalLights = new Color(),\n\t\t\t_pointLights = new Color(),\n\t\t\t_clearColor = new Color(),\n\n\t\t\t_vector3 = new Vector3(), // Needed for PointLight\n\t\t\t_centroid = new Vector3(),\n\t\t\t_normal = new Vector3(),\n\t\t\t_normalViewMatrix = new Matrix3(),\n\n\t\t\t_viewMatrix = new Matrix4(),\n\t\t\t_viewProjectionMatrix = new Matrix4(),\n\n\t\t\t_svgPathPool = [],\n\n\t\t\t_projector = new Projector(),\n\t\t\t_svg = document.createElementNS( 'http://www.w3.org/2000/svg', 'svg' );\n\n\t\tthis.domElement = _svg;\n\n\t\tthis.autoClear = true;\n\t\tthis.sortObjects = true;\n\t\tthis.sortElements = true;\n\n\t\tthis.overdraw = 0.5;\n\n\t\tthis.info = {\n\n\t\t\trender: {\n\n\t\t\t\tvertices: 0,\n\t\t\t\tfaces: 0\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.setQuality = function ( quality ) {\n\n\t\t\tswitch ( quality ) {\n\n\t\t\t\tcase 'high': _quality = 1; break;\n\t\t\t\tcase 'low': _quality = 0; break;\n\n\t\t\t}\n\n\t\t};\n\n\t\tthis.setClearColor = function ( color ) {\n\n\t\t\t_clearColor.set( color );\n\n\t\t};\n\n\t\tthis.setPixelRatio = function () {};\n\n\t\tthis.setSize = function ( width, height ) {\n\n\t\t\t_svgWidth = width; _svgHeight = height;\n\t\t\t_svgWidthHalf = _svgWidth / 2; _svgHeightHalf = _svgHeight / 2;\n\n\t\t\t_svg.setAttribute( 'viewBox', ( - _svgWidthHalf ) + ' ' + ( - _svgHeightHalf ) + ' ' + _svgWidth + ' ' + _svgHeight );\n\t\t\t_svg.setAttribute( 'width', _svgWidth );\n\t\t\t_svg.setAttribute( 'height', _svgHeight );\n\n\t\t\t_clipBox.min.set( - _svgWidthHalf, - _svgHeightHalf );\n\t\t\t_clipBox.max.set( _svgWidthHalf, _svgHeightHalf );\n\n\t\t};\n\n\t\tthis.getSize = function () {\n\n\t\t\treturn {\n\t\t\t\twidth: _svgWidth,\n\t\t\t\theight: _svgHeight\n\t\t\t};\n\n\t\t};\n\n\t\tthis.setPrecision = function ( precision ) {\n\n\t\t\t_precision = precision;\n\n\t\t};\n\n\t\tfunction removeChildNodes() {\n\n\t\t\t_pathCount = 0;\n\n\t\t\twhile ( _svg.childNodes.length > 0 ) {\n\n\t\t\t\t_svg.removeChild( _svg.childNodes[ 0 ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction convert( c ) {\n\n\t\t\treturn _precision !== null ? c.toFixed( _precision ) : c;\n\n\t\t}\n\n\t\tthis.clear = function () {\n\n\t\t\tremoveChildNodes();\n\t\t\t_svg.style.backgroundColor = _clearColor.getStyle();\n\n\t\t};\n\n\t\tthis.render = function ( scene, camera ) {\n\n\t\t\tif ( camera instanceof Camera === false ) {\n\n\t\t\t\tconsole.error( 'THREE.SVGRenderer.render: camera is not an instance of Camera.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t\tconst background = scene.background;\n\n\t\t\tif ( background && background.isColor ) {\n\n\t\t\t\tremoveChildNodes();\n\t\t\t\t_svg.style.backgroundColor = background.getStyle();\n\n\t\t\t} else if ( this.autoClear === true ) {\n\n\t\t\t\tthis.clear();\n\n\t\t\t}\n\n\t\t\t_this.info.render.vertices = 0;\n\t\t\t_this.info.render.faces = 0;\n\n\t\t\t_viewMatrix.copy( camera.matrixWorldInverse );\n\t\t\t_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );\n\n\t\t\t_renderData = _projector.projectScene( scene, camera, this.sortObjects, this.sortElements );\n\t\t\t_elements = _renderData.elements;\n\t\t\t_lights = _renderData.lights;\n\n\t\t\t_normalViewMatrix.getNormalMatrix( camera.matrixWorldInverse );\n\n\t\t\tcalculateLights( _lights );\n\n\t\t\t // reset accumulated path\n\n\t\t\t_currentPath = '';\n\t\t\t_currentStyle = '';\n\n\t\t\tfor ( let e = 0, el = _elements.length; e < el; e ++ ) {\n\n\t\t\t\tconst element = _elements[ e ];\n\t\t\t\tconst material = element.material;\n\n\t\t\t\tif ( material === undefined || material.opacity === 0 ) continue;\n\n\t\t\t\t_elemBox.makeEmpty();\n\n\t\t\t\tif ( element instanceof RenderableSprite ) {\n\n\t\t\t\t\t_v1 = element;\n\t\t\t\t\t_v1.x *= _svgWidthHalf; _v1.y *= - _svgHeightHalf;\n\n\t\t\t\t\trenderSprite( _v1, element, material );\n\n\t\t\t\t} else if ( element instanceof RenderableLine ) {\n\n\t\t\t\t\t_v1 = element.v1; _v2 = element.v2;\n\n\t\t\t\t\t_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;\n\t\t\t\t\t_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;\n\n\t\t\t\t\t_elemBox.setFromPoints( [ _v1.positionScreen, _v2.positionScreen ] );\n\n\t\t\t\t\tif ( _clipBox.intersectsBox( _elemBox ) === true ) {\n\n\t\t\t\t\t\trenderLine( _v1, _v2, material );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( element instanceof RenderableFace ) {\n\n\t\t\t\t\t_v1 = element.v1; _v2 = element.v2; _v3 = element.v3;\n\n\t\t\t\t\tif ( _v1.positionScreen.z < - 1 || _v1.positionScreen.z > 1 ) continue;\n\t\t\t\t\tif ( _v2.positionScreen.z < - 1 || _v2.positionScreen.z > 1 ) continue;\n\t\t\t\t\tif ( _v3.positionScreen.z < - 1 || _v3.positionScreen.z > 1 ) continue;\n\n\t\t\t\t\t_v1.positionScreen.x *= _svgWidthHalf; _v1.positionScreen.y *= - _svgHeightHalf;\n\t\t\t\t\t_v2.positionScreen.x *= _svgWidthHalf; _v2.positionScreen.y *= - _svgHeightHalf;\n\t\t\t\t\t_v3.positionScreen.x *= _svgWidthHalf; _v3.positionScreen.y *= - _svgHeightHalf;\n\n\t\t\t\t\tif ( this.overdraw > 0 ) {\n\n\t\t\t\t\t\texpand( _v1.positionScreen, _v2.positionScreen, this.overdraw );\n\t\t\t\t\t\texpand( _v2.positionScreen, _v3.positionScreen, this.overdraw );\n\t\t\t\t\t\texpand( _v3.positionScreen, _v1.positionScreen, this.overdraw );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_elemBox.setFromPoints( [\n\t\t\t\t\t\t_v1.positionScreen,\n\t\t\t\t\t\t_v2.positionScreen,\n\t\t\t\t\t\t_v3.positionScreen\n\t\t\t\t\t] );\n\n\t\t\t\t\tif ( _clipBox.intersectsBox( _elemBox ) === true ) {\n\n\t\t\t\t\t\trenderFace3( _v1, _v2, _v3, element, material );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tflushPath(); // just to flush last svg:path\n\n\t\t\tscene.traverseVisible( function ( object ) {\n\n\t\t\t\t if ( object.isSVGObject ) {\n\n\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld );\n\t\t\t\t\t_vector3.applyMatrix4( _viewProjectionMatrix );\n\n\t\t\t\t\tif ( _vector3.z < - 1 || _vector3.z > 1 ) return;\n\n\t\t\t\t\tconst x = _vector3.x * _svgWidthHalf;\n\t\t\t\t\tconst y = - _vector3.y * _svgHeightHalf;\n\n\t\t\t\t\tconst node = object.node;\n\t\t\t\t\tnode.setAttribute( 'transform', 'translate(' + x + ',' + y + ')' );\n\n\t\t\t\t\t_svg.appendChild( node );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t};\n\n\t\tfunction calculateLights( lights ) {\n\n\t\t\t_ambientLight.setRGB( 0, 0, 0 );\n\t\t\t_directionalLights.setRGB( 0, 0, 0 );\n\t\t\t_pointLights.setRGB( 0, 0, 0 );\n\n\t\t\tfor ( let l = 0, ll = lights.length; l < ll; l ++ ) {\n\n\t\t\t\tconst light = lights[ l ];\n\t\t\t\tconst lightColor = light.color;\n\n\t\t\t\tif ( light.isAmbientLight ) {\n\n\t\t\t\t\t_ambientLight.r += lightColor.r;\n\t\t\t\t\t_ambientLight.g += lightColor.g;\n\t\t\t\t\t_ambientLight.b += lightColor.b;\n\n\t\t\t\t} else if ( light.isDirectionalLight ) {\n\n\t\t\t\t\t_directionalLights.r += lightColor.r;\n\t\t\t\t\t_directionalLights.g += lightColor.g;\n\t\t\t\t\t_directionalLights.b += lightColor.b;\n\n\t\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\t\t_pointLights.r += lightColor.r;\n\t\t\t\t\t_pointLights.g += lightColor.g;\n\t\t\t\t\t_pointLights.b += lightColor.b;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction calculateLight( lights, position, normal, color ) {\n\n\t\t\tfor ( let l = 0, ll = lights.length; l < ll; l ++ ) {\n\n\t\t\t\tconst light = lights[ l ];\n\t\t\t\tconst lightColor = light.color;\n\n\t\t\t\tif ( light.isDirectionalLight ) {\n\n\t\t\t\t\tconst lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld )\n\t\t\t\t\t\t.sub( _normal.setFromMatrixPosition( light.target.matrixWorld ) )\n\t\t\t\t\t\t.normalize();\n\n\t\t\t\t\tlet amount = normal.dot( lightPosition );\n\n\t\t\t\t\tif ( amount <= 0 ) continue;\n\n\t\t\t\t\tamount *= light.intensity;\n\n\t\t\t\t\tcolor.r += lightColor.r * amount;\n\t\t\t\t\tcolor.g += lightColor.g * amount;\n\t\t\t\t\tcolor.b += lightColor.b * amount;\n\n\t\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\t\tconst lightPosition = _vector3.setFromMatrixPosition( light.matrixWorld );\n\n\t\t\t\t\tlet amount = normal.dot( _vector3.subVectors( lightPosition, position ).normalize() );\n\n\t\t\t\t\tif ( amount <= 0 ) continue;\n\n\t\t\t\t\tamount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( lightPosition ) / light.distance, 1 );\n\n\t\t\t\t\tif ( amount == 0 ) continue;\n\n\t\t\t\t\tamount *= light.intensity;\n\n\t\t\t\t\tcolor.r += lightColor.r * amount;\n\t\t\t\t\tcolor.g += lightColor.g * amount;\n\t\t\t\t\tcolor.b += lightColor.b * amount;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction renderSprite( v1, element, material ) {\n\n\t\t\tlet scaleX = element.scale.x * _svgWidthHalf;\n\t\t\tlet scaleY = element.scale.y * _svgHeightHalf;\n\n\t\t\tif ( material.isPointsMaterial ) {\n\n\t\t\t\tscaleX *= material.size;\n\t\t\t\tscaleY *= material.size;\n\n\t\t\t}\n\n\t\t\tconst path = 'M' + convert( v1.x - scaleX * 0.5 ) + ',' + convert( v1.y - scaleY * 0.5 ) + 'h' + convert( scaleX ) + 'v' + convert( scaleY ) + 'h' + convert( - scaleX ) + 'z';\n\t\t\tlet style = '';\n\n\t\t\tif ( material.isSpriteMaterial || material.isPointsMaterial ) {\n\n\t\t\t\tstyle = 'fill:' + material.color.getStyle() + ';fill-opacity:' + material.opacity;\n\n\t\t\t}\n\n\t\t\taddPath( style, path );\n\n\t\t}\n\n\t\tfunction renderLine( v1, v2, material ) {\n\n\t\t\tconst path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y );\n\n\t\t\tif ( material.isLineBasicMaterial ) {\n\n\t\t\t\tlet style = 'fill:none;stroke:' + material.color.getStyle() + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.linewidth + ';stroke-linecap:' + material.linecap;\n\n\t\t\t\tif ( material.isLineDashedMaterial ) {\n\n\t\t\t\t\tstyle = style + ';stroke-dasharray:' + material.dashSize + ',' + material.gapSize;\n\n\t\t\t\t}\n\n\t\t\t\taddPath( style, path );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction renderFace3( v1, v2, v3, element, material ) {\n\n\t\t\t_this.info.render.vertices += 3;\n\t\t\t_this.info.render.faces ++;\n\n\t\t\tconst path = 'M' + convert( v1.positionScreen.x ) + ',' + convert( v1.positionScreen.y ) + 'L' + convert( v2.positionScreen.x ) + ',' + convert( v2.positionScreen.y ) + 'L' + convert( v3.positionScreen.x ) + ',' + convert( v3.positionScreen.y ) + 'z';\n\t\t\tlet style = '';\n\n\t\t\tif ( material.isMeshBasicMaterial ) {\n\n\t\t\t\t_color.copy( material.color );\n\n\t\t\t\tif ( material.vertexColors ) {\n\n\t\t\t\t\t_color.multiply( element.color );\n\n\t\t\t\t}\n\n\t\t\t} else if ( material.isMeshLambertMaterial || material.isMeshPhongMaterial || material.isMeshStandardMaterial ) {\n\n\t\t\t\t_diffuseColor.copy( material.color );\n\n\t\t\t\tif ( material.vertexColors ) {\n\n\t\t\t\t\t_diffuseColor.multiply( element.color );\n\n\t\t\t\t}\n\n\t\t\t\t_color.copy( _ambientLight );\n\n\t\t\t\t_centroid.copy( v1.positionWorld ).add( v2.positionWorld ).add( v3.positionWorld ).divideScalar( 3 );\n\n\t\t\t\tcalculateLight( _lights, _centroid, element.normalModel, _color );\n\n\t\t\t\t_color.multiply( _diffuseColor ).add( material.emissive );\n\n\t\t\t} else if ( material.isMeshNormalMaterial ) {\n\n\t\t\t\t_normal.copy( element.normalModel ).applyMatrix3( _normalViewMatrix ).normalize();\n\n\t\t\t\t_color.setRGB( _normal.x, _normal.y, _normal.z ).multiplyScalar( 0.5 ).addScalar( 0.5 );\n\n\t\t\t}\n\n\t\t\tif ( material.wireframe ) {\n\n\t\t\t\tstyle = 'fill:none;stroke:' + _color.getStyle() + ';stroke-opacity:' + material.opacity + ';stroke-width:' + material.wireframeLinewidth + ';stroke-linecap:' + material.wireframeLinecap + ';stroke-linejoin:' + material.wireframeLinejoin;\n\n\t\t\t} else {\n\n\t\t\t\tstyle = 'fill:' + _color.getStyle() + ';fill-opacity:' + material.opacity;\n\n\t\t\t}\n\n\t\t\taddPath( style, path );\n\n\t\t}\n\n\t\t// Hide anti-alias gaps\n\n\t\tfunction expand( v1, v2, pixels ) {\n\n\t\t\tlet x = v2.x - v1.x, y = v2.y - v1.y;\n\t\t\tconst det = x * x + y * y;\n\n\t\t\tif ( det === 0 ) return;\n\n\t\t\tconst idet = pixels / Math.sqrt( det );\n\n\t\t\tx *= idet; y *= idet;\n\n\t\t\tv2.x += x; v2.y += y;\n\t\t\tv1.x -= x; v1.y -= y;\n\n\t\t}\n\n\t\tfunction addPath( style, path ) {\n\n\t\t\tif ( _currentStyle === style ) {\n\n\t\t\t\t_currentPath += path;\n\n\t\t\t} else {\n\n\t\t\t\tflushPath();\n\n\t\t\t\t_currentStyle = style;\n\t\t\t\t_currentPath = path;\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction flushPath() {\n\n\t\t\tif ( _currentPath ) {\n\n\t\t\t\t_svgNode = getPathNode( _pathCount ++ );\n\t\t\t\t_svgNode.setAttribute( 'd', _currentPath );\n\t\t\t\t_svgNode.setAttribute( 'style', _currentStyle );\n\t\t\t\t_svg.appendChild( _svgNode );\n\n\t\t\t}\n\n\t\t\t_currentPath = '';\n\t\t\t_currentStyle = '';\n\n\t\t}\n\n\t\tfunction getPathNode( id ) {\n\n\t\t\tif ( _svgPathPool[ id ] == null ) {\n\n\t\t\t\t_svgPathPool[ id ] = document.createElementNS( 'http://www.w3.org/2000/svg', 'path' );\n\n\t\t\t\tif ( _quality == 0 ) {\n\n\t\t\t\t\t_svgPathPool[ id ].setAttribute( 'shape-rendering', 'crispEdges' ); //optimizeSpeed\n\n\t\t\t\t}\n\n\t\t\t\treturn _svgPathPool[ id ];\n\n\t\t\t}\n\n\t\t\treturn _svgPathPool[ id ];\n\n\t\t}\n\n\t}\n\n}\n\nexport { SVGObject, SVGRenderer };\n","/**\n * @license\n * uiconfig.js v0.1.3\n * Copyright 2022-2025 repalash <palash@shaders.app>\n * MIT License\n */\n\n/**\n * @license\n * ts-browser-helpers v0.16.2\n * Copyright 2022-2025 repalash <palash@shaders.app>\n * MIT License\n * See ./dependencies.txt for bundled third-party dependencies and licenses.\n */\nclass I {\n constructor() {\n this._eventListeners = {}, this.dispatchEvent = this.dispatchEvent.bind(this), this.addEventListener = this.addEventListener.bind(this), this.removeEventListener = this.removeEventListener.bind(this), this.hasEventListener = this.hasEventListener.bind(this);\n }\n addEventListener(e, t) {\n const i = this._eventListeners;\n i[e] === void 0 && (i[e] = []), i[e].includes(t) || i[e].push(t);\n }\n hasEventListener(e, t) {\n const i = this._eventListeners;\n return i[e] !== void 0 && i[e].includes(t);\n }\n removeEventListener(e, t) {\n const r = this._eventListeners[e];\n if (r !== void 0) {\n const s = r.indexOf(t);\n s !== -1 && r.splice(s, 1);\n }\n }\n dispatchEvent(e) {\n const i = this._eventListeners[e.type];\n if (i !== void 0) {\n e.target = this;\n const r = i.slice(0);\n for (let s = 0, o = r.length; s < o; s++) r[s].call(this, e);\n }\n }\n}\nasync function X(n) {\n return new Promise((e) => setTimeout(e, Math.max(0, n)));\n}\nfunction g() {\n return (typeof performance > \"u\" ? Date : performance).now();\n}\n/*!\n * Fork Of -\n * JavaScript Undo Manager 1.0.0\n * Simple JavaScript undo/redo command manager supporting transactions with no dependencies.\n *\n * Copyright: Alexey Grinko, 2017\n * Git repository: https://github.com/agrinko/js-undo-manager.git\n *\n * @license MIT - https://opensource.org/licenses/MIT\n *\n * Changes -\n * 1. Added presets commands\n * 2. Port to TypeScript\n * 3. Remove transactions\n */\nclass Q {\n constructor(e) {\n this.options = {\n limit: 500,\n // maximum commands stack size\n debug: !1,\n // whether to emit execution status in console\n bindHotKeys: !1\n // whether to bind \"undo\" and \"redo\" commands to \"Ctrl+Z\", \"Ctrl+Y\" & \"Ctrl+Shift+Z\" hot keys\n // useTransactions: true // whether to initialize transactions manager\n }, this.enabled = !0, this.presets = {}, this._keyDown = (t) => {\n if (!this.enabled) return;\n const i = t.ctrlKey || t.metaKey;\n t.code === \"KeyZ\" && i && !t.shiftKey ? this.undo() : (t.code === \"KeyZ\" && i && t.shiftKey || t.code === \"KeyY\" && t.ctrlKey) && this.redo();\n }, Object.assign(this.options, e), this.limit = e.limit, this.options = e, this.reset(), e.bindHotKeys && this.bindHotKeys(), this.log(`Initialized with stack limit of ${this.limit} commands`);\n }\n /**\n * Bind 'undo' and 'redo' actions to 'Ctrl/Cmd+Z', 'Ctrl+Y' & 'Ctrl/Cmd+Shift+Z' hot keys.\n * It is a basic implementation for quick testing and should be replaced with custom event handlers\n * for more flexible processing.\n * @returns {JSUndoManager}\n */\n bindHotKeys() {\n return this.log(\"Bound 'undo' and 'redo' actions to 'Ctrl/Cmd+Z', 'Ctrl+Y' & 'Ctrl/Cmd+Shift+Z' hot keys\"), (this.options.hotKeyRoot ?? document).addEventListener(\"keydown\", this._keyDown), this;\n }\n dispose() {\n return (this.options.hotKeyRoot ?? document).removeEventListener(\"keydown\", this._keyDown), this.reset();\n }\n /**\n * Remember executed command containing \"redo\" and \"undo\" functions\n * @param {Object|Function} command - either an object with \"redo\" and \"undo\" functions\n * @returns {JSUndoManager}\n */\n record(e) {\n return this.enabled ? (this._record(e), this) : this;\n }\n replaceLast(e) {\n const t = this.peek();\n if (t)\n return this.log(\"replace\", t, \"with\", e), this.stack[this.sp] = e, this;\n }\n /**\n * Execute function and record it with its opposite \"undo\" function\n * @param {Object|Function} command - either an object with \"redo\" and \"undo\" functions\n * @param {Function} [undo] - \"undo\" function, used if the first argument is also a function\n * @returns {JSUndoManager}\n */\n execute(e) {\n if (!this.enabled) return;\n let t = this._rc(e), i = t.redo;\n return this.record.apply(this, t), this.log(\"Executing function...\"), i.apply(e), this;\n }\n _rc(e) {\n if (e.type) {\n const t = this.presets[e.type];\n if (typeof t == \"function\")\n return t(e);\n throw console.error(e, t, this.presets), new Error(\"Preset command not found\");\n } else\n return e;\n }\n _record(e) {\n this.enabled && (this.log(\"Recording command\", e), this._rebase(), this.stack.push(e), this.sp++, this._keepLimit());\n }\n //forget \"future\" commands if stack pointer is not at the end\n _rebase() {\n this.canRedo() && (this.stack.length = this.sp + 1);\n }\n //sustain limited size of stack; cut extra commands starting with the latest ones\n _keepLimit() {\n if (this.stack.length <= this.limit)\n return;\n let e = this.stack.length - this.limit;\n this.log(\"Stack size reached its limit: ${this.limit} commands. Cutting off most old commands...\"), e === 1 ? this.stack.shift() : this.stack.splice(0, e), this.sp -= e;\n }\n /**\n * Undo previous command if possible\n * @returns {JSUndoManager}\n */\n undo() {\n if (!this.canUndo())\n return this;\n let e = this.stack[this.sp];\n return this.log(\"undo\"), this.sp--, this._rc(e).undo(), this;\n }\n /**\n * Check whether undoing previous command is possible\n * @returns {boolean}\n */\n canUndo() {\n return this.sp >= 0 && this.enabled;\n }\n /**\n * Get the last command that was done\n */\n peek() {\n return this.canUndo() ? this.stack[this.sp] : null;\n }\n /**\n * Redo the command which was previously undone\n * @returns {JSUndoManager}\n */\n redo() {\n if (!this.canRedo())\n return this;\n let e = this.stack[this.sp + 1];\n return this.log(\"redo\"), this.sp++, this._rc(e).redo(), this;\n }\n /**\n * Check whether redoing command is possible\n * @returns {boolean}\n */\n canRedo() {\n return this.sp < this.stack.length - 1 && this.enabled;\n }\n /**\n * Gets the last command that was undone\n */\n peekForward() {\n return this.canRedo() ? this.stack[this.sp + 1] : null;\n }\n /**\n * Change stack size limit initially defined in the constructor options\n * @param {number} limit\n */\n setLimit(e) {\n let t = this.stack.length - this.sp - 1;\n if (e < 1 || typeof e != \"number\")\n throw new TypeError(`JSUndoManager.setLimit(): unexpected argument limit=${e}. Should be a positive number`);\n return e < t ? console.warn(`JSUndoManager.setLimit(): cannot set stack limit (${e}) less than the number of 'redoable' commands (${t})`) : (this.limit = Math.floor(e), this._keepLimit()), this;\n }\n /**\n * Reset all commands from memory\n */\n reset() {\n return this.log(\"reset\"), this.stack = [], this.sp = -1, this;\n }\n /**\n * Check whether the commands stack is empty\n * @returns {boolean}\n */\n isEmpty() {\n return !this.stack.length;\n }\n /**\n * Check whether the commands stack size reaches its limit\n * @returns {boolean}\n */\n isFull() {\n return this.stack.length === this.limit;\n }\n /**\n * Get number of commands in memory stack\n * @returns {Number}\n */\n getSize() {\n r