summit/frontend/node_modules/three-stdlib/loaders/LDrawLoader.cjs.map

1 line
88 KiB
Plaintext
Raw Normal View History

2025-12-08 16:31:30 +00:00
{"version":3,"file":"LDrawLoader.cjs","sources":["../../src/loaders/LDrawLoader.js"],"sourcesContent":["import {\n BufferAttribute,\n BufferGeometry,\n Color,\n FileLoader,\n Group,\n LineBasicMaterial,\n LineSegments,\n Loader,\n Matrix4,\n Mesh,\n MeshStandardMaterial,\n ShaderMaterial,\n UniformsLib,\n UniformsUtils,\n Vector3,\n Ray,\n} from 'three'\nimport { version } from '../_polyfill/constants'\n\n// Special surface finish tag types.\n// Note: \"MATERIAL\" tag (e.g. GLITTER, SPECKLE) is not implemented\nconst FINISH_TYPE_DEFAULT = 0\nconst FINISH_TYPE_CHROME = 1\nconst FINISH_TYPE_PEARLESCENT = 2\nconst FINISH_TYPE_RUBBER = 3\nconst FINISH_TYPE_MATTE_METALLIC = 4\nconst FINISH_TYPE_METAL = 5\n\n// State machine to search a subobject path.\n// The LDraw standard establishes these various possible subfolders.\nconst FILE_LOCATION_AS_IS = 0\nconst FILE_LOCATION_TRY_PARTS = 1\nconst FILE_LOCATION_TRY_P = 2\nconst FILE_LOCATION_TRY_MODELS = 3\nconst FILE_LOCATION_TRY_RELATIVE = 4\nconst FILE_LOCATION_TRY_ABSOLUTE = 5\nconst FILE_LOCATION_NOT_FOUND = 6\n\nconst MAIN_COLOUR_CODE = '16'\nconst MAIN_EDGE_COLOUR_CODE = '24'\n\nconst _tempVec0 = /* @__PURE__ */ new Vector3()\nconst _tempVec1 = /* @__PURE__ */ new Vector3()\n\nclass LDrawConditionalLineMaterial extends ShaderMaterial {\n constructor(parameters) {\n super({\n uniforms: UniformsUtils.merge([\n UniformsLib.fog,\n {\n diffuse: {\n value: new Color(),\n },\n opacity: {\n value: 1.0,\n },\n },\n ]),\n\n vertexShader: /* glsl */ `\n attribute vec3 control0;\n attribute vec3 control1;\n attribute vec3 direction;\n varying float discardFlag;\n\n #include <common>\n #include <color_pars_vertex>\n #include <fog_pars_vertex>\n #include <logdepthbuf_pars_vertex>\n #include <clipping_planes_pars_vertex>\n\n void main() {\n #include <color_vertex>\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_Position = projectionMatrix * mvPosition;\n\n // Transform the line segment ends and control points into camera clip space\n vec4 c0 = projectionMatrix * modelViewMatrix * vec4(control0, 1.0);\n vec4 c1 = projectionMatrix * modelViewMatrix * vec4(control1, 1.0);\n vec4 p0 = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n vec4 p1 = projectionMatrix * modelViewMatrix * vec4(position + direction, 1.0);\n\n c0.xy /= c0.w;\n c1.xy /= c1.w;\n p0.xy /= p0.w;\n p1.xy /= p1.w;\n\n // Get the direction of the segment and an orthogonal vector\n vec2 dir = p1.xy - p0.xy;\n vec2 norm = vec2(-dir.y, dir.x);\n\n // Get control point directions from the line\n vec2 c0dir = c0.xy - p1.xy;\n vec2 c1dir = c1.xy - p1.xy;\n\n // If the vectors to the controls points are pointed in different directions away\n // from the line segment then the line should not be drawn.\n float d0 = dot(normalize(norm), normalize(c0dir));\n float d1 = dot(normalize(norm), normalize(c1dir));\n discardFlag = float(sign(d0) != sign(d1));\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n }\n `,\n\n fragmentShader: /* glsl */ `\n uniform vec3 diffuse;\n uniform float opacity;\n varying float discardFlag;\n\n #include <common>\n #include <color_pars_fragment>\n #include <fog_pars_fragment>\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n\n void main() {\n if (discardFlag > 0.5) discard;\n\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3(0.0);\n vec4 diffuseColor = vec4(diffuse, opacity);\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n o