├── fixtures └── threejs_src │ ├── Three.Legacy.js │ ├── .DS_Store │ ├── extras │ ├── .DS_Store │ ├── curves │ │ ├── ArcCurve.js │ │ ├── Curves.js │ │ ├── QuadraticBezierCurve.js │ │ ├── QuadraticBezierCurve3.js │ │ ├── CubicBezierCurve.js │ │ ├── LineCurve3.js │ │ ├── CubicBezierCurve3.js │ │ ├── LineCurve.js │ │ └── SplineCurve.js │ ├── core │ │ ├── Interpolations.js │ │ └── Shape.js │ └── ShapeUtils.js │ ├── renderers │ ├── .DS_Store │ ├── shaders │ │ ├── ShaderChunk │ │ │ ├── colorspace_fragment.glsl.js │ │ │ ├── fog_pars_vertex.glsl.js │ │ │ ├── fog_vertex.glsl.js │ │ │ ├── map_pars_fragment.glsl.js │ │ │ ├── alphatest_pars_fragment.glsl.js │ │ │ ├── default_fragment.glsl.js │ │ │ ├── lights_toon_fragment.glsl.js │ │ │ ├── alphamap_pars_fragment.glsl.js │ │ │ ├── emissivemap_pars_fragment.glsl.js │ │ │ ├── specularmap_pars_fragment.glsl.js │ │ │ ├── alphatest_fragment.glsl.js │ │ │ ├── clipping_planes_pars_vertex.glsl.js │ │ │ ├── clipping_planes_vertex.glsl.js │ │ │ ├── dithering_fragment.glsl.js │ │ │ ├── metalnessmap_pars_fragment.glsl.js │ │ │ ├── roughnessmap_pars_fragment.glsl.js │ │ │ ├── clearcoat_normal_fragment_begin.glsl.js │ │ │ ├── default_vertex.glsl.js │ │ │ ├── alphamap_fragment.glsl.js │ │ │ ├── aomap_pars_fragment.glsl.js │ │ │ ├── tonemapping_fragment.glsl.js │ │ │ ├── alphahash_fragment.glsl.js │ │ │ ├── lightmap_pars_fragment.glsl.js │ │ │ ├── begin_vertex.glsl.js │ │ │ ├── lights_lambert_fragment.glsl.js │ │ │ ├── beginnormal_vertex.glsl.js │ │ │ ├── color_pars_fragment.glsl.js │ │ │ ├── color_fragment.glsl.js │ │ │ ├── clipping_planes_pars_fragment.glsl.js │ │ │ ├── emissivemap_fragment.glsl.js │ │ │ ├── displacementmap_pars_vertex.glsl.js │ │ │ ├── color_pars_vertex.glsl.js │ │ │ ├── normal_pars_vertex.glsl.js │ │ │ ├── displacementmap_vertex.glsl.js │ │ │ ├── normal_pars_fragment.glsl.js │ │ │ ├── logdepthbuf_pars_fragment.glsl.js │ │ │ ├── lights_phong_fragment.glsl.js │ │ │ ├── opaque_fragment.glsl.js │ │ │ ├── premultiplied_alpha_fragment.glsl.js │ │ │ ├── iridescence_pars_fragment.glsl.js │ │ │ ├── logdepthbuf_pars_vertex.glsl.js │ │ │ ├── lightmap_fragment.glsl.js │ │ │ ├── envmap_common_pars_fragment.glsl.js │ │ │ ├── skinbase_vertex.glsl.js │ │ │ ├── specularmap_fragment.glsl.js │ │ │ ├── project_vertex.glsl.js │ │ │ ├── fog_pars_fragment.glsl.js │ │ │ ├── clearcoat_normal_fragment_maps.glsl.js │ │ │ ├── lights_fragment_end.glsl.js │ │ │ ├── metalnessmap_fragment.glsl.js │ │ │ ├── roughnessmap_fragment.glsl.js │ │ │ ├── logdepthbuf_fragment.glsl.js │ │ │ ├── normal_vertex.glsl.js │ │ │ ├── fog_fragment.glsl.js │ │ │ ├── clearcoat_pars_fragment.glsl.js │ │ │ ├── color_vertex.glsl.js │ │ │ ├── envmap_pars_vertex.glsl.js │ │ │ ├── worldpos_vertex.glsl.js │ │ │ ├── map_particle_pars_fragment.glsl.js │ │ │ ├── envmap_pars_fragment.glsl.js │ │ │ ├── skinning_vertex.glsl.js │ │ │ ├── logdepthbuf_vertex.glsl.js │ │ │ ├── map_particle_fragment.glsl.js │ │ │ ├── skinnormal_vertex.glsl.js │ │ │ ├── map_fragment.glsl.js │ │ │ ├── aomap_fragment.glsl.js │ │ │ ├── gradientmap_pars_fragment.glsl.js │ │ │ ├── dithering_pars_fragment.glsl.js │ │ │ ├── clipping_planes_fragment.glsl.js │ │ │ ├── normal_fragment_maps.glsl.js │ │ │ ├── envmap_vertex.glsl.js │ │ │ ├── defaultnormal_vertex.glsl.js │ │ │ ├── lights_toon_pars_fragment.glsl.js │ │ │ ├── skinning_pars_vertex.glsl.js │ │ │ ├── morphcolor_vertex.glsl.js │ │ │ ├── bsdfs.glsl.js │ │ │ ├── lights_lambert_pars_fragment.glsl.js │ │ │ ├── morphtarget_pars_vertex.glsl.js │ │ │ ├── morphnormal_vertex.glsl.js │ │ │ ├── lights_fragment_maps.glsl.js │ │ │ ├── normalmap_pars_fragment.glsl.js │ │ │ ├── transmission_fragment.glsl.js │ │ │ ├── lights_phong_pars_fragment.glsl.js │ │ │ ├── bumpmap_pars_fragment.glsl.js │ │ │ ├── morphtarget_vertex.glsl.js │ │ │ ├── colorspace_pars_fragment.glsl.js │ │ │ ├── envmap_fragment.glsl.js │ │ │ ├── shadowmap_pars_vertex.glsl.js │ │ │ ├── normal_fragment_begin.glsl.js │ │ │ ├── shadowmask_pars_fragment.glsl.js │ │ │ └── envmap_physical_pars_fragment.glsl.js │ │ └── ShaderLib │ │ │ ├── equirect.glsl.js │ │ │ ├── cube.glsl.js │ │ │ ├── background.glsl.js │ │ │ ├── backgroundCube.glsl.js │ │ │ ├── shadow.glsl.js │ │ │ ├── vsm.glsl.js │ │ │ ├── linedashed.glsl.js │ │ │ ├── distanceRGBA.glsl.js │ │ │ └── meshnormal.glsl.js │ ├── WebGL1Renderer.js │ ├── webgl │ │ ├── WebGLShader.js │ │ ├── WebGLProperties.js │ │ ├── WebGLAnimation.js │ │ ├── WebGLBufferRenderer.js │ │ ├── WebGLInfo.js │ │ ├── WebGLIndexedBufferRenderer.js │ │ └── WebGLObjects.js │ ├── WebGLRenderTarget.js │ ├── WebGL3DRenderTarget.js │ ├── WebGLArrayRenderTarget.js │ └── WebGLMultipleRenderTargets.js │ ├── objects │ ├── Bone.js │ ├── Group.js │ ├── LineLoop.js │ └── LineSegments.js │ ├── core │ ├── Uniform.js │ ├── InstancedBufferGeometry.js │ ├── InstancedBufferAttribute.js │ ├── Layers.js │ ├── InstancedInterleavedBuffer.js │ ├── GLBufferAttribute.js │ ├── Clock.js │ ├── UniformsGroup.js │ └── EventDispatcher.js │ ├── lights │ ├── AmbientLight.js │ ├── DirectionalLightShadow.js │ ├── HemisphereLight.js │ ├── LightProbe.js │ ├── DirectionalLight.js │ ├── SpotLightShadow.js │ ├── RectAreaLight.js │ ├── PointLight.js │ ├── Light.js │ └── SpotLight.js │ ├── cameras │ ├── ArrayCamera.js │ └── Camera.js │ ├── materials │ ├── RawShaderMaterial.js │ ├── ShadowMaterial.js │ ├── LineDashedMaterial.js │ ├── MeshDistanceMaterial.js │ ├── PointsMaterial.js │ ├── LineBasicMaterial.js │ ├── SpriteMaterial.js │ ├── MeshDepthMaterial.js │ ├── MeshNormalMaterial.js │ ├── Materials.js │ ├── MeshMatcapMaterial.js │ └── MeshBasicMaterial.js │ ├── animation │ └── tracks │ │ ├── NumberKeyframeTrack.js │ │ ├── VectorKeyframeTrack.js │ │ ├── ColorKeyframeTrack.js │ │ ├── StringKeyframeTrack.js │ │ ├── BooleanKeyframeTrack.js │ │ └── QuaternionKeyframeTrack.js │ ├── audio │ ├── AudioContext.js │ └── AudioAnalyser.js │ ├── textures │ ├── CanvasTexture.js │ ├── FramebufferTexture.js │ ├── CompressedArrayTexture.js │ ├── CompressedCubeTexture.js │ ├── DataArrayTexture.js │ ├── DataTexture.js │ ├── CubeTexture.js │ ├── CompressedTexture.js │ ├── Data3DTexture.js │ ├── VideoTexture.js │ └── DepthTexture.js │ ├── scenes │ ├── FogExp2.js │ ├── Fog.js │ └── Scene.js │ ├── math │ ├── interpolants │ │ ├── DiscreteInterpolant.js │ │ ├── LinearInterpolant.js │ │ └── QuaternionLinearInterpolant.js │ ├── Cylindrical.js │ └── Spherical.js │ ├── loaders │ ├── Cache.js │ ├── TextureLoader.js │ ├── CubeTextureLoader.js │ ├── AnimationLoader.js │ ├── Loader.js │ ├── AudioLoader.js │ ├── LoaderUtils.js │ └── ImageLoader.js │ ├── geometries │ ├── TetrahedronGeometry.js │ ├── OctahedronGeometry.js │ ├── Geometries.js │ ├── CapsuleGeometry.js │ ├── ConeGeometry.js │ ├── IcosahedronGeometry.js │ └── DodecahedronGeometry.js │ ├── helpers │ ├── Box3Helper.js │ ├── GridHelper.js │ ├── AxesHelper.js │ └── PlaneHelper.js │ └── utils.js ├── src ├── source_map │ └── mod.rs ├── type_aliases.rs ├── lib.rs ├── span.rs ├── magic_string │ ├── prepend.rs │ ├── source_map.rs │ └── append.rs └── joiner.rs ├── .gitattributes ├── README.md ├── .vscode └── settings.json ├── renovate.json ├── rustfmt.toml ├── .editorconfig ├── .gitignore ├── tests ├── joiner.rs └── magic_string_source_map.rs ├── Cargo.toml ├── examples └── source_map.rs ├── LICENSE └── benches └── joiner_join.rs /fixtures/threejs_src/Three.Legacy.js: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/source_map/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod locator; 2 | pub mod sourcemap_builder; 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | 2 | # Ignore fxtures 3 | fixtures/**/*.js -linguist-detectable 4 | -------------------------------------------------------------------------------- /fixtures/threejs_src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolldown/string_wizard/HEAD/fixtures/threejs_src/.DS_Store -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolldown/string_wizard/HEAD/fixtures/threejs_src/extras/.DS_Store -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rolldown/string_wizard/HEAD/fixtures/threejs_src/renderers/.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The crate is currently maintained in https://github.com/rolldown/rolldown/tree/main/crates/string_wizard. 2 | 3 | # string_wizard 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "outro" 4 | ], 5 | "rust-analyzer.cargo.features": [ 6 | "source_map" 7 | ] 8 | } -------------------------------------------------------------------------------- /src/type_aliases.rs: -------------------------------------------------------------------------------- 1 | use index_vec::IndexVec; 2 | 3 | use crate::chunk::{Chunk, ChunkIdx}; 4 | 5 | pub type IndexChunks<'text> = IndexVec>; 6 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/colorspace_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | gl_FragColor = linearToOutputTexel( gl_FragColor ); 3 | `; 4 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | varying float vFogDepth; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | vFogDepth = - mvPosition.z; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MAP 3 | 4 | uniform sampler2D map; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHATEST 3 | uniform float alphaTest; 4 | #endif 5 | `; 6 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/default_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | void main() { 3 | gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); 4 | } 5 | `; 6 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | ToonMaterial material; 3 | material.diffuseColor = diffuseColor.rgb; 4 | `; 5 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHAMAP 3 | 4 | uniform sampler2D alphaMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_EMISSIVEMAP 3 | 4 | uniform sampler2D emissiveMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SPECULARMAP 3 | 4 | uniform sampler2D specularMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHATEST 3 | 4 | if ( diffuseColor.a < alphaTest ) discard; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 3 | 4 | varying vec3 vClipPosition; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 3 | 4 | vClipPosition = - mvPosition.xyz; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef DITHERING 3 | 4 | gl_FragColor.rgb = dithering( gl_FragColor.rgb ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_METALNESSMAP 3 | 4 | uniform sampler2D metalnessMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ROUGHNESSMAP 3 | 4 | uniform sampler2D roughnessMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_CLEARCOAT 3 | 4 | vec3 clearcoatNormal = geometryNormal; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/default_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | void main() { 3 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); 4 | } 5 | `; 6 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHAMAP 3 | 4 | diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_AOMAP 3 | 4 | uniform sampler2D aoMap; 5 | uniform float aoMapIntensity; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( TONE_MAPPING ) 3 | 4 | gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/alphahash_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHAHASH 3 | 4 | if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LIGHTMAP 3 | 4 | uniform sampler2D lightMap; 5 | uniform float lightMapIntensity; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 transformed = vec3( position ); 3 | 4 | #ifdef USE_ALPHAHASH 5 | 6 | vPosition = vec3( position ); 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | LambertMaterial material; 3 | material.diffuseColor = diffuseColor.rgb; 4 | material.specularStrength = specularStrength; 5 | `; 6 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/WebGL1Renderer.js: -------------------------------------------------------------------------------- 1 | import { WebGLRenderer } from './WebGLRenderer.js'; 2 | 3 | class WebGL1Renderer extends WebGLRenderer {} 4 | 5 | WebGL1Renderer.prototype.isWebGL1Renderer = true; 6 | 7 | export { WebGL1Renderer }; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 objectNormal = vec3( normal ); 3 | 4 | #ifdef USE_TANGENT 5 | 6 | vec3 objectTangent = vec3( tangent.xyz ); 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:best-practices", 5 | ":automergeMinor", 6 | ":automergeRequireAllStatusChecks", 7 | ":automergePr" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /rustfmt.toml: -------------------------------------------------------------------------------- 1 | tab_spaces = 2 2 | 3 | # This is also the setting used by [rustc](https://github.com/rust-lang/rust/blob/master/rustfmt.toml) 4 | use_small_heuristics = "Max" 5 | 6 | # Use field initialize shorthand if possible 7 | use_field_init_shorthand = true 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = false 12 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_COLOR_ALPHA ) 3 | 4 | varying vec4 vColor; 5 | 6 | #elif defined( USE_COLOR ) 7 | 8 | varying vec3 vColor; 9 | 10 | #endif 11 | `; 12 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/color_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_COLOR_ALPHA ) 3 | 4 | diffuseColor *= vColor; 5 | 6 | #elif defined( USE_COLOR ) 7 | 8 | diffuseColor.rgb *= vColor; 9 | 10 | #endif 11 | `; 12 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 3 | 4 | varying vec3 vClipPosition; 5 | 6 | uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_EMISSIVEMAP 3 | 4 | vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); 5 | 6 | totalEmissiveRadiance *= emissiveColor.rgb; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /fixtures/threejs_src/objects/Bone.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | 3 | class Bone extends Object3D { 4 | 5 | constructor() { 6 | 7 | super(); 8 | 9 | this.isBone = true; 10 | 11 | this.type = 'Bone'; 12 | 13 | } 14 | 15 | } 16 | 17 | export { Bone }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_DISPLACEMENTMAP 3 | 4 | uniform sampler2D displacementMap; 5 | uniform float displacementScale; 6 | uniform float displacementBias; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /fixtures/threejs_src/objects/Group.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | 3 | class Group extends Object3D { 4 | 5 | constructor() { 6 | 7 | super(); 8 | 9 | this.isGroup = true; 10 | 11 | this.type = 'Group'; 12 | 13 | } 14 | 15 | } 16 | 17 | export { Group }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLShader.js: -------------------------------------------------------------------------------- 1 | function WebGLShader( gl, type, string ) { 2 | 3 | const shader = gl.createShader( type ); 4 | 5 | gl.shaderSource( shader, string ); 6 | gl.compileShader( shader ); 7 | 8 | return shader; 9 | 10 | } 11 | 12 | export { WebGLShader }; 13 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_COLOR_ALPHA ) 3 | 4 | varying vec4 vColor; 5 | 6 | #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) 7 | 8 | varying vec3 vColor; 9 | 10 | #endif 11 | `; 12 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifndef FLAT_SHADED 3 | 4 | varying vec3 vNormal; 5 | 6 | #ifdef USE_TANGENT 7 | 8 | varying vec3 vTangent; 9 | varying vec3 vBitangent; 10 | 11 | #endif 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_DISPLACEMENTMAP 3 | 4 | transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifndef FLAT_SHADED 3 | 4 | varying vec3 vNormal; 5 | 6 | #ifdef USE_TANGENT 7 | 8 | varying vec3 vTangent; 9 | varying vec3 vBitangent; 10 | 11 | #endif 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/Uniform.js: -------------------------------------------------------------------------------- 1 | class Uniform { 2 | 3 | constructor( value ) { 4 | 5 | this.value = value; 6 | 7 | } 8 | 9 | clone() { 10 | 11 | return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() ); 12 | 13 | } 14 | 15 | } 16 | 17 | export { Uniform }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) 3 | 4 | uniform float logDepthBufFC; 5 | varying float vFragDepth; 6 | varying float vIsPerspective; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | BlinnPhongMaterial material; 3 | material.diffuseColor = diffuseColor.rgb; 4 | material.specularColor = specular; 5 | material.specularShininess = shininess; 6 | material.specularStrength = specularStrength; 7 | `; 8 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/opaque_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef OPAQUE 3 | diffuseColor.a = 1.0; 4 | #endif 5 | 6 | #ifdef USE_TRANSMISSION 7 | diffuseColor.a *= material.transmissionAlpha; 8 | #endif 9 | 10 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 11 | `; 12 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef PREMULTIPLIED_ALPHA 3 | 4 | // Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation. 5 | gl_FragColor.rgb *= gl_FragColor.a; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /fixtures/threejs_src/objects/LineLoop.js: -------------------------------------------------------------------------------- 1 | import { Line } from './Line.js'; 2 | 3 | class LineLoop extends Line { 4 | 5 | constructor( geometry, material ) { 6 | 7 | super( geometry, material ); 8 | 9 | this.isLineLoop = true; 10 | 11 | this.type = 'LineLoop'; 12 | 13 | } 14 | 15 | } 16 | 17 | export { LineLoop }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | #ifdef USE_IRIDESCENCEMAP 4 | 5 | uniform sampler2D iridescenceMap; 6 | 7 | #endif 8 | 9 | #ifdef USE_IRIDESCENCE_THICKNESSMAP 10 | 11 | uniform sampler2D iridescenceThicknessMap; 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/AmbientLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | 3 | class AmbientLight extends Light { 4 | 5 | constructor( color, intensity ) { 6 | 7 | super( color, intensity ); 8 | 9 | this.isAmbientLight = true; 10 | 11 | this.type = 'AmbientLight'; 12 | 13 | } 14 | 15 | } 16 | 17 | export { AmbientLight }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LOGDEPTHBUF 3 | 4 | #ifdef USE_LOGDEPTHBUF_EXT 5 | 6 | varying float vFragDepth; 7 | varying float vIsPerspective; 8 | 9 | #else 10 | 11 | uniform float logDepthBufFC; 12 | 13 | #endif 14 | 15 | #endif 16 | `; 17 | -------------------------------------------------------------------------------- /fixtures/threejs_src/cameras/ArrayCamera.js: -------------------------------------------------------------------------------- 1 | import { PerspectiveCamera } from './PerspectiveCamera.js'; 2 | 3 | class ArrayCamera extends PerspectiveCamera { 4 | 5 | constructor( array = [] ) { 6 | 7 | super(); 8 | 9 | this.isArrayCamera = true; 10 | 11 | this.cameras = array; 12 | 13 | } 14 | 15 | } 16 | 17 | export { ArrayCamera }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LIGHTMAP 3 | 4 | vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 5 | vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; 6 | 7 | reflectedLight.indirectDiffuse += lightMapIrradiance; 8 | 9 | #endif 10 | `; 11 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | uniform float envMapIntensity; 5 | uniform float flipEnvMap; 6 | 7 | #ifdef ENVMAP_TYPE_CUBE 8 | uniform samplerCube envMap; 9 | #else 10 | uniform sampler2D envMap; 11 | #endif 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | mat4 boneMatX = getBoneMatrix( skinIndex.x ); 5 | mat4 boneMatY = getBoneMatrix( skinIndex.y ); 6 | mat4 boneMatZ = getBoneMatrix( skinIndex.z ); 7 | mat4 boneMatW = getBoneMatrix( skinIndex.w ); 8 | 9 | #endif 10 | `; 11 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float specularStrength; 3 | 4 | #ifdef USE_SPECULARMAP 5 | 6 | vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); 7 | specularStrength = texelSpecular.r; 8 | 9 | #else 10 | 11 | specularStrength = 1.0; 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/project_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec4 mvPosition = vec4( transformed, 1.0 ); 3 | 4 | #ifdef USE_INSTANCING 5 | 6 | mvPosition = instanceMatrix * mvPosition; 7 | 8 | #endif 9 | 10 | mvPosition = modelViewMatrix * mvPosition; 11 | 12 | gl_Position = projectionMatrix * mvPosition; 13 | `; 14 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | uniform vec3 fogColor; 5 | varying float vFogDepth; 6 | 7 | #ifdef FOG_EXP2 8 | 9 | uniform float fogDensity; 10 | 11 | #else 12 | 13 | uniform float fogNear; 14 | uniform float fogFar; 15 | 16 | #endif 17 | 18 | #endif 19 | `; 20 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/WebGLRenderTarget.js: -------------------------------------------------------------------------------- 1 | import { RenderTarget } from '../core/RenderTarget.js'; 2 | 3 | class WebGLRenderTarget extends RenderTarget { 4 | 5 | constructor( width = 1, height = 1, options = {} ) { 6 | 7 | super( width, height, options ); 8 | 9 | this.isWebGLRenderTarget = true; 10 | 11 | } 12 | 13 | } 14 | 15 | export { WebGLRenderTarget }; 16 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_CLEARCOAT_NORMALMAP 3 | 4 | vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; 5 | clearcoatMapN.xy *= clearcoatNormalScale; 6 | 7 | clearcoatNormal = normalize( tbn2 * clearcoatMapN ); 8 | 9 | #endif 10 | `; 11 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/RawShaderMaterial.js: -------------------------------------------------------------------------------- 1 | import { ShaderMaterial } from './ShaderMaterial.js'; 2 | 3 | class RawShaderMaterial extends ShaderMaterial { 4 | 5 | constructor( parameters ) { 6 | 7 | super( parameters ); 8 | 9 | this.isRawShaderMaterial = true; 10 | 11 | this.type = 'RawShaderMaterial'; 12 | 13 | } 14 | 15 | } 16 | 17 | export { RawShaderMaterial }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/animation/tracks/NumberKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { KeyframeTrack } from '../KeyframeTrack.js'; 2 | 3 | /** 4 | * A Track of numeric keyframe values. 5 | */ 6 | class NumberKeyframeTrack extends KeyframeTrack {} 7 | 8 | NumberKeyframeTrack.prototype.ValueTypeName = 'number'; 9 | // ValueBufferType is inherited 10 | // DefaultInterpolation is inherited 11 | 12 | export { NumberKeyframeTrack }; 13 | -------------------------------------------------------------------------------- /fixtures/threejs_src/animation/tracks/VectorKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { KeyframeTrack } from '../KeyframeTrack.js'; 2 | 3 | /** 4 | * A Track of vectored keyframe values. 5 | */ 6 | class VectorKeyframeTrack extends KeyframeTrack {} 7 | 8 | VectorKeyframeTrack.prototype.ValueTypeName = 'vector'; 9 | // ValueBufferType is inherited 10 | // DefaultInterpolation is inherited 11 | 12 | export { VectorKeyframeTrack }; 13 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( RE_IndirectDiffuse ) 3 | 4 | RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); 5 | 6 | #endif 7 | 8 | #if defined( RE_IndirectSpecular ) 9 | 10 | RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight ); 11 | 12 | #endif 13 | `; 14 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float metalnessFactor = metalness; 3 | 4 | #ifdef USE_METALNESSMAP 5 | 6 | vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); 7 | 8 | // reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture 9 | metalnessFactor *= texelMetalness.b; 10 | 11 | #endif 12 | `; 13 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float roughnessFactor = roughness; 3 | 4 | #ifdef USE_ROUGHNESSMAP 5 | 6 | vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); 7 | 8 | // reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture 9 | roughnessFactor *= texelRoughness.g; 10 | 11 | #endif 12 | `; 13 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) 3 | 4 | // Doing a strict comparison with == 1.0 can cause noise artifacts 5 | // on some platforms. See issue #17623. 6 | gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifndef FLAT_SHADED // normal is computed with derivatives when FLAT_SHADED 3 | 4 | vNormal = normalize( transformedNormal ); 5 | 6 | #ifdef USE_TANGENT 7 | 8 | vTangent = normalize( transformedTangent ); 9 | vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); 10 | 11 | #endif 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/audio/AudioContext.js: -------------------------------------------------------------------------------- 1 | let _context; 2 | 3 | class AudioContext { 4 | 5 | static getContext() { 6 | 7 | if ( _context === undefined ) { 8 | 9 | _context = new ( window.AudioContext || window.webkitAudioContext )(); 10 | 11 | } 12 | 13 | return _context; 14 | 15 | } 16 | 17 | static setContext( value ) { 18 | 19 | _context = value; 20 | 21 | } 22 | 23 | } 24 | 25 | export { AudioContext }; 26 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/ArcCurve.js: -------------------------------------------------------------------------------- 1 | import { EllipseCurve } from './EllipseCurve.js'; 2 | 3 | class ArcCurve extends EllipseCurve { 4 | 5 | constructor( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { 6 | 7 | super( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); 8 | 9 | this.isArcCurve = true; 10 | 11 | this.type = 'ArcCurve'; 12 | 13 | } 14 | 15 | } 16 | 17 | export { ArcCurve }; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | #ifdef FOG_EXP2 5 | 6 | float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); 7 | 8 | #else 9 | 10 | float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); 11 | 12 | #endif 13 | 14 | gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); 15 | 16 | #endif 17 | `; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/DirectionalLightShadow.js: -------------------------------------------------------------------------------- 1 | import { LightShadow } from './LightShadow.js'; 2 | import { OrthographicCamera } from '../cameras/OrthographicCamera.js'; 3 | 4 | class DirectionalLightShadow extends LightShadow { 5 | 6 | constructor() { 7 | 8 | super( new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) ); 9 | 10 | this.isDirectionalLightShadow = true; 11 | 12 | } 13 | 14 | } 15 | 16 | export { DirectionalLightShadow }; 17 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | #ifdef USE_CLEARCOATMAP 4 | 5 | uniform sampler2D clearcoatMap; 6 | 7 | #endif 8 | 9 | #ifdef USE_CLEARCOAT_NORMALMAP 10 | 11 | uniform sampler2D clearcoatNormalMap; 12 | uniform vec2 clearcoatNormalScale; 13 | 14 | #endif 15 | 16 | #ifdef USE_CLEARCOAT_ROUGHNESSMAP 17 | 18 | uniform sampler2D clearcoatRoughnessMap; 19 | 20 | #endif 21 | `; 22 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/color_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_COLOR_ALPHA ) 3 | 4 | vColor = vec4( 1.0 ); 5 | 6 | #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) 7 | 8 | vColor = vec3( 1.0 ); 9 | 10 | #endif 11 | 12 | #ifdef USE_COLOR 13 | 14 | vColor *= color; 15 | 16 | #endif 17 | 18 | #ifdef USE_INSTANCING_COLOR 19 | 20 | vColor.xyz *= instanceColor.xyz; 21 | 22 | #endif 23 | `; 24 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/CanvasTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | 3 | class CanvasTexture extends Texture { 4 | 5 | constructor( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { 6 | 7 | super( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); 8 | 9 | this.isCanvasTexture = true; 10 | 11 | this.needsUpdate = true; 12 | 13 | } 14 | 15 | } 16 | 17 | export { CanvasTexture }; 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 8 | Cargo.lock 9 | 10 | # These are backup files generated by rustfmt 11 | **/*.rs.bk 12 | 13 | # MSVC Windows builds of rustc generate these, which store debugging information 14 | *.pdb 15 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 5 | 6 | #define ENV_WORLDPOS 7 | 8 | #endif 9 | 10 | #ifdef ENV_WORLDPOS 11 | 12 | varying vec3 vWorldPosition; 13 | 14 | #else 15 | 16 | varying vec3 vReflect; 17 | uniform float refractionRatio; 18 | 19 | #endif 20 | 21 | #endif 22 | `; 23 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 3 | 4 | vec4 worldPosition = vec4( transformed, 1.0 ); 5 | 6 | #ifdef USE_INSTANCING 7 | 8 | worldPosition = instanceMatrix * worldPosition; 9 | 10 | #endif 11 | 12 | worldPosition = modelMatrix * worldPosition; 13 | 14 | #endif 15 | `; 16 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_POINTS_UV ) 3 | 4 | varying vec2 vUv; 5 | 6 | #else 7 | 8 | #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 9 | 10 | uniform mat3 uvTransform; 11 | 12 | #endif 13 | 14 | #endif 15 | 16 | #ifdef USE_MAP 17 | 18 | uniform sampler2D map; 19 | 20 | #endif 21 | 22 | #ifdef USE_ALPHAMAP 23 | 24 | uniform sampler2D alphaMap; 25 | 26 | #endif 27 | `; 28 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | mod chunk; 2 | mod joiner; 3 | mod magic_string; 4 | #[cfg(feature = "source_map")] 5 | mod source_map; 6 | mod span; 7 | mod type_aliases; 8 | 9 | type CowStr<'a> = Cow<'a, str>; 10 | 11 | use std::borrow::Cow; 12 | 13 | pub use crate::{ 14 | joiner::{Joiner, JoinerOptions}, 15 | magic_string::{indent::IndentOptions, update::UpdateOptions, MagicString, MagicStringOptions}, 16 | }; 17 | 18 | #[cfg(feature = "source_map")] 19 | pub use crate::magic_string::source_map::SourceMapOptions; 20 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | uniform float reflectivity; 5 | 6 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) 7 | 8 | #define ENV_WORLDPOS 9 | 10 | #endif 11 | 12 | #ifdef ENV_WORLDPOS 13 | 14 | varying vec3 vWorldPosition; 15 | uniform float refractionRatio; 16 | #else 17 | varying vec3 vReflect; 18 | #endif 19 | 20 | #endif 21 | `; 22 | -------------------------------------------------------------------------------- /src/span.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Default, Clone, Copy)] 2 | pub struct Span(pub usize, pub usize); 3 | 4 | impl Span { 5 | pub fn start(&self) -> usize { 6 | self.0 7 | } 8 | 9 | pub fn end(&self) -> usize { 10 | self.1 11 | } 12 | 13 | pub fn text<'s>(&self, source: &'s str) -> &'s str { 14 | // This crate doesn't support usize which is u16 on 16-bit platforms. 15 | // So, we can safely cast usize/u32 to usize. 16 | &source[self.start() as usize..self.end() as usize] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); 5 | 6 | vec4 skinned = vec4( 0.0 ); 7 | skinned += boneMatX * skinVertex * skinWeight.x; 8 | skinned += boneMatY * skinVertex * skinWeight.y; 9 | skinned += boneMatZ * skinVertex * skinWeight.z; 10 | skinned += boneMatW * skinVertex * skinWeight.w; 11 | 12 | transformed = ( bindMatrixInverse * skinned ).xyz; 13 | 14 | #endif 15 | `; 16 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/FramebufferTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | import { NearestFilter } from '../constants.js'; 3 | 4 | class FramebufferTexture extends Texture { 5 | 6 | constructor( width, height ) { 7 | 8 | super( { width, height } ); 9 | 10 | this.isFramebufferTexture = true; 11 | 12 | this.magFilter = NearestFilter; 13 | this.minFilter = NearestFilter; 14 | 15 | this.generateMipmaps = false; 16 | 17 | this.needsUpdate = true; 18 | 19 | } 20 | 21 | } 22 | 23 | export { FramebufferTexture }; 24 | -------------------------------------------------------------------------------- /fixtures/threejs_src/animation/tracks/ColorKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { KeyframeTrack } from '../KeyframeTrack.js'; 2 | 3 | /** 4 | * A Track of keyframe values that represent color. 5 | */ 6 | class ColorKeyframeTrack extends KeyframeTrack {} 7 | 8 | ColorKeyframeTrack.prototype.ValueTypeName = 'color'; 9 | // ValueBufferType is inherited 10 | // DefaultInterpolation is inherited 11 | 12 | // Note: Very basic implementation and nothing special yet. 13 | // However, this is the place for color space parameterization. 14 | 15 | export { ColorKeyframeTrack }; 16 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LOGDEPTHBUF 3 | 4 | #ifdef USE_LOGDEPTHBUF_EXT 5 | 6 | vFragDepth = 1.0 + gl_Position.w; 7 | vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); 8 | 9 | #else 10 | 11 | if ( isPerspectiveMatrix( projectionMatrix ) ) { 12 | 13 | gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; 14 | 15 | gl_Position.z *= gl_Position.w; 16 | 17 | } 18 | 19 | #endif 20 | 21 | #endif 22 | `; 23 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/CompressedArrayTexture.js: -------------------------------------------------------------------------------- 1 | import { ClampToEdgeWrapping } from '../constants.js'; 2 | import { CompressedTexture } from './CompressedTexture.js'; 3 | 4 | class CompressedArrayTexture extends CompressedTexture { 5 | 6 | constructor( mipmaps, width, height, depth, format, type ) { 7 | 8 | super( mipmaps, width, height, format, type ); 9 | 10 | this.isCompressedArrayTexture = true; 11 | this.image.depth = depth; 12 | this.wrapR = ClampToEdgeWrapping; 13 | 14 | } 15 | 16 | } 17 | 18 | export { CompressedArrayTexture }; 19 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) 3 | 4 | #if defined( USE_POINTS_UV ) 5 | 6 | vec2 uv = vUv; 7 | 8 | #else 9 | 10 | vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; 11 | 12 | #endif 13 | 14 | #endif 15 | 16 | #ifdef USE_MAP 17 | 18 | diffuseColor *= texture2D( map, uv ); 19 | 20 | #endif 21 | 22 | #ifdef USE_ALPHAMAP 23 | 24 | diffuseColor.a *= texture2D( alphaMap, uv ).g; 25 | 26 | #endif 27 | `; 28 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/CompressedCubeTexture.js: -------------------------------------------------------------------------------- 1 | import { CubeReflectionMapping } from '../constants.js'; 2 | import { CompressedTexture } from './CompressedTexture.js'; 3 | 4 | class CompressedCubeTexture extends CompressedTexture { 5 | 6 | constructor( images, format, type ) { 7 | 8 | super( undefined, images[ 0 ].width, images[ 0 ].height, format, type, CubeReflectionMapping ); 9 | 10 | this.isCompressedCubeTexture = true; 11 | this.isCubeTexture = true; 12 | 13 | this.image = images; 14 | 15 | } 16 | 17 | } 18 | 19 | export { CompressedCubeTexture }; 20 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/Curves.js: -------------------------------------------------------------------------------- 1 | export { ArcCurve } from './ArcCurve.js'; 2 | export { CatmullRomCurve3 } from './CatmullRomCurve3.js'; 3 | export { CubicBezierCurve } from './CubicBezierCurve.js'; 4 | export { CubicBezierCurve3 } from './CubicBezierCurve3.js'; 5 | export { EllipseCurve } from './EllipseCurve.js'; 6 | export { LineCurve } from './LineCurve.js'; 7 | export { LineCurve3 } from './LineCurve3.js'; 8 | export { QuadraticBezierCurve } from './QuadraticBezierCurve.js'; 9 | export { QuadraticBezierCurve3 } from './QuadraticBezierCurve3.js'; 10 | export { SplineCurve } from './SplineCurve.js'; 11 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/WebGL3DRenderTarget.js: -------------------------------------------------------------------------------- 1 | import { WebGLRenderTarget } from './WebGLRenderTarget.js'; 2 | import { Data3DTexture } from '../textures/Data3DTexture.js'; 3 | 4 | class WebGL3DRenderTarget extends WebGLRenderTarget { 5 | 6 | constructor( width = 1, height = 1, depth = 1 ) { 7 | 8 | super( width, height ); 9 | 10 | this.isWebGL3DRenderTarget = true; 11 | 12 | this.depth = depth; 13 | 14 | this.texture = new Data3DTexture( null, width, height, depth ); 15 | 16 | this.texture.isRenderTargetTexture = true; 17 | 18 | } 19 | 20 | } 21 | 22 | export { WebGL3DRenderTarget }; 23 | -------------------------------------------------------------------------------- /fixtures/threejs_src/scenes/FogExp2.js: -------------------------------------------------------------------------------- 1 | import { Color } from '../math/Color.js'; 2 | 3 | class FogExp2 { 4 | 5 | constructor( color, density = 0.00025 ) { 6 | 7 | this.isFogExp2 = true; 8 | 9 | this.name = ''; 10 | 11 | this.color = new Color( color ); 12 | this.density = density; 13 | 14 | } 15 | 16 | clone() { 17 | 18 | return new FogExp2( this.color, this.density ); 19 | 20 | } 21 | 22 | toJSON( /* meta */ ) { 23 | 24 | return { 25 | type: 'FogExp2', 26 | color: this.color.getHex(), 27 | density: this.density 28 | }; 29 | 30 | } 31 | 32 | } 33 | 34 | export { FogExp2 }; 35 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/WebGLArrayRenderTarget.js: -------------------------------------------------------------------------------- 1 | import { WebGLRenderTarget } from './WebGLRenderTarget.js'; 2 | import { DataArrayTexture } from '../textures/DataArrayTexture.js'; 3 | 4 | class WebGLArrayRenderTarget extends WebGLRenderTarget { 5 | 6 | constructor( width = 1, height = 1, depth = 1 ) { 7 | 8 | super( width, height ); 9 | 10 | this.isWebGLArrayRenderTarget = true; 11 | 12 | this.depth = depth; 13 | 14 | this.texture = new DataArrayTexture( null, width, height, depth ); 15 | 16 | this.texture.isRenderTargetTexture = true; 17 | 18 | } 19 | 20 | } 21 | 22 | export { WebGLArrayRenderTarget }; 23 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | mat4 skinMatrix = mat4( 0.0 ); 5 | skinMatrix += skinWeight.x * boneMatX; 6 | skinMatrix += skinWeight.y * boneMatY; 7 | skinMatrix += skinWeight.z * boneMatZ; 8 | skinMatrix += skinWeight.w * boneMatW; 9 | skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; 10 | 11 | objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; 12 | 13 | #ifdef USE_TANGENT 14 | 15 | objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; 16 | 17 | #endif 18 | 19 | #endif 20 | `; 21 | -------------------------------------------------------------------------------- /fixtures/threejs_src/scenes/Fog.js: -------------------------------------------------------------------------------- 1 | import { Color } from '../math/Color.js'; 2 | 3 | class Fog { 4 | 5 | constructor( color, near = 1, far = 1000 ) { 6 | 7 | this.isFog = true; 8 | 9 | this.name = ''; 10 | 11 | this.color = new Color( color ); 12 | 13 | this.near = near; 14 | this.far = far; 15 | 16 | } 17 | 18 | clone() { 19 | 20 | return new Fog( this.color, this.near, this.far ); 21 | 22 | } 23 | 24 | toJSON( /* meta */ ) { 25 | 26 | return { 27 | type: 'Fog', 28 | color: this.color.getHex(), 29 | near: this.near, 30 | far: this.far 31 | }; 32 | 33 | } 34 | 35 | } 36 | 37 | export { Fog }; 38 | -------------------------------------------------------------------------------- /fixtures/threejs_src/math/interpolants/DiscreteInterpolant.js: -------------------------------------------------------------------------------- 1 | import { Interpolant } from '../Interpolant.js'; 2 | 3 | /** 4 | * 5 | * Interpolant that evaluates to the sample value at the position preceding 6 | * the parameter. 7 | */ 8 | 9 | class DiscreteInterpolant extends Interpolant { 10 | 11 | constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { 12 | 13 | super( parameterPositions, sampleValues, sampleSize, resultBuffer ); 14 | 15 | } 16 | 17 | interpolate_( i1 /*, t0, t, t1 */ ) { 18 | 19 | return this.copySampleValue_( i1 - 1 ); 20 | 21 | } 22 | 23 | } 24 | 25 | 26 | export { DiscreteInterpolant }; 27 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/map_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MAP 3 | 4 | vec4 sampledDiffuseColor = texture2D( map, vMapUv ); 5 | 6 | #ifdef DECODE_VIDEO_TEXTURE 7 | 8 | // use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures 9 | 10 | sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); 11 | 12 | #endif 13 | 14 | diffuseColor *= sampledDiffuseColor; 15 | 16 | #endif 17 | `; 18 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_AOMAP 3 | 4 | // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture 5 | float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0; 6 | 7 | reflectedLight.indirectDiffuse *= ambientOcclusion; 8 | 9 | #if defined( USE_ENVMAP ) && defined( STANDARD ) 10 | 11 | float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); 12 | 13 | reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness ); 14 | 15 | #endif 16 | 17 | #endif 18 | `; 19 | -------------------------------------------------------------------------------- /tests/joiner.rs: -------------------------------------------------------------------------------- 1 | use string_wizard::{Joiner, JoinerOptions, MagicString}; 2 | mod append { 3 | use super::*; 4 | 5 | #[test] 6 | fn should_append_content() { 7 | let mut j = Joiner::default(); 8 | j.append(MagicString::new("*")); 9 | j.append_raw("123").append_raw("456"); 10 | assert_eq!(j.join(), "*123456"); 11 | } 12 | } 13 | 14 | #[test] 15 | fn separator() { 16 | let mut j = Joiner::with_options(JoinerOptions { separator: Some(",".to_string()) }); 17 | j.append_raw("123"); 18 | assert_eq!(j.join(), "123"); 19 | j.append_raw("123"); 20 | assert_eq!(j.join(), "123,123"); 21 | j.append_raw("123"); 22 | assert_eq!(j.join(), "123,123,123"); 23 | } 24 | -------------------------------------------------------------------------------- /fixtures/threejs_src/animation/tracks/StringKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { InterpolateDiscrete } from '../../constants.js'; 2 | import { KeyframeTrack } from '../KeyframeTrack.js'; 3 | 4 | /** 5 | * A Track that interpolates Strings 6 | */ 7 | class StringKeyframeTrack extends KeyframeTrack {} 8 | 9 | StringKeyframeTrack.prototype.ValueTypeName = 'string'; 10 | StringKeyframeTrack.prototype.ValueBufferType = Array; 11 | StringKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; 12 | StringKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; 13 | StringKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; 14 | 15 | export { StringKeyframeTrack }; 16 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | #ifdef USE_GRADIENTMAP 4 | 5 | uniform sampler2D gradientMap; 6 | 7 | #endif 8 | 9 | vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 10 | 11 | // dotNL will be from -1.0 to 1.0 12 | float dotNL = dot( normal, lightDirection ); 13 | vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); 14 | 15 | #ifdef USE_GRADIENTMAP 16 | 17 | return vec3( texture2D( gradientMap, coord ).r ); 18 | 19 | #else 20 | 21 | vec2 fw = fwidth( coord ) * 0.5; 22 | return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); 23 | 24 | #endif 25 | 26 | } 27 | `; 28 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/DataArrayTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; 3 | 4 | class DataArrayTexture extends Texture { 5 | 6 | constructor( data = null, width = 1, height = 1, depth = 1 ) { 7 | 8 | super( null ); 9 | 10 | this.isDataArrayTexture = true; 11 | 12 | this.image = { data, width, height, depth }; 13 | 14 | this.magFilter = NearestFilter; 15 | this.minFilter = NearestFilter; 16 | 17 | this.wrapR = ClampToEdgeWrapping; 18 | 19 | this.generateMipmaps = false; 20 | this.flipY = false; 21 | this.unpackAlignment = 1; 22 | 23 | } 24 | 25 | } 26 | 27 | export { DataArrayTexture }; 28 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/ShadowMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | class ShadowMaterial extends Material { 5 | 6 | constructor( parameters ) { 7 | 8 | super(); 9 | 10 | this.isShadowMaterial = true; 11 | 12 | this.type = 'ShadowMaterial'; 13 | 14 | this.color = new Color( 0x000000 ); 15 | this.transparent = true; 16 | 17 | this.fog = true; 18 | 19 | this.setValues( parameters ); 20 | 21 | } 22 | 23 | copy( source ) { 24 | 25 | super.copy( source ); 26 | 27 | this.color.copy( source.color ); 28 | 29 | this.fog = source.fog; 30 | 31 | return this; 32 | 33 | } 34 | 35 | } 36 | 37 | export { ShadowMaterial }; 38 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/Cache.js: -------------------------------------------------------------------------------- 1 | const Cache = { 2 | 3 | enabled: false, 4 | 5 | files: {}, 6 | 7 | add: function ( key, file ) { 8 | 9 | if ( this.enabled === false ) return; 10 | 11 | // console.log( 'THREE.Cache', 'Adding key:', key ); 12 | 13 | this.files[ key ] = file; 14 | 15 | }, 16 | 17 | get: function ( key ) { 18 | 19 | if ( this.enabled === false ) return; 20 | 21 | // console.log( 'THREE.Cache', 'Checking key:', key ); 22 | 23 | return this.files[ key ]; 24 | 25 | }, 26 | 27 | remove: function ( key ) { 28 | 29 | delete this.files[ key ]; 30 | 31 | }, 32 | 33 | clear: function () { 34 | 35 | this.files = {}; 36 | 37 | } 38 | 39 | }; 40 | 41 | 42 | export { Cache }; 43 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/LineDashedMaterial.js: -------------------------------------------------------------------------------- 1 | import { LineBasicMaterial } from './LineBasicMaterial.js'; 2 | 3 | class LineDashedMaterial extends LineBasicMaterial { 4 | 5 | constructor( parameters ) { 6 | 7 | super(); 8 | 9 | this.isLineDashedMaterial = true; 10 | 11 | this.type = 'LineDashedMaterial'; 12 | 13 | this.scale = 1; 14 | this.dashSize = 3; 15 | this.gapSize = 1; 16 | 17 | this.setValues( parameters ); 18 | 19 | } 20 | 21 | copy( source ) { 22 | 23 | super.copy( source ); 24 | 25 | this.scale = source.scale; 26 | this.dashSize = source.dashSize; 27 | this.gapSize = source.gapSize; 28 | 29 | return this; 30 | 31 | } 32 | 33 | } 34 | 35 | export { LineDashedMaterial }; 36 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/DataTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | import { NearestFilter } from '../constants.js'; 3 | 4 | class DataTexture extends Texture { 5 | 6 | constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, colorSpace ) { 7 | 8 | super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace ); 9 | 10 | this.isDataTexture = true; 11 | 12 | this.image = { data: data, width: width, height: height }; 13 | 14 | this.generateMipmaps = false; 15 | this.flipY = false; 16 | this.unpackAlignment = 1; 17 | 18 | } 19 | 20 | } 21 | 22 | export { DataTexture }; 23 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "string_wizard" 3 | version = "0.0.22" 4 | edition = "2021" 5 | license = "MIT" 6 | description = "manipulate string like a wizard" 7 | 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [dependencies] 11 | index_vec = { version = "0.1.3" } 12 | rustc-hash = { version = "1.1.0" } 13 | oxc_sourcemap = { version = "0.25.0", optional = true} 14 | 15 | [features] 16 | # Enable source map functionality 17 | source_map = ['dep:oxc_sourcemap'] 18 | 19 | [dev-dependencies] 20 | glob = "0.3.1" 21 | criterion = { version = "0.4" } 22 | insta = "1.31.0" 23 | 24 | [[bench]] 25 | name = "joiner_join" 26 | harness = false 27 | 28 | [profile.release] 29 | debug = true -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef DITHERING 3 | 4 | // based on https://www.shadertoy.com/view/MslGR8 5 | vec3 dithering( vec3 color ) { 6 | //Calculate grid position 7 | float grid_position = rand( gl_FragCoord.xy ); 8 | 9 | //Shift the individual colors differently, thus making it even harder to see the dithering pattern 10 | vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); 11 | 12 | //modify shift according to grid position. 13 | dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); 14 | 15 | //shift the color by dither_shift 16 | return color + dither_shift_RGB; 17 | } 18 | 19 | #endif 20 | `; 21 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/equirect.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | varying vec3 vWorldDirection; 3 | 4 | #include 5 | 6 | void main() { 7 | 8 | vWorldDirection = transformDirection( position, modelMatrix ); 9 | 10 | #include 11 | #include 12 | 13 | } 14 | `; 15 | 16 | export const fragment = /* glsl */` 17 | uniform sampler2D tEquirect; 18 | 19 | varying vec3 vWorldDirection; 20 | 21 | #include 22 | 23 | void main() { 24 | 25 | vec3 direction = normalize( vWorldDirection ); 26 | 27 | vec2 sampleUV = equirectUv( direction ); 28 | 29 | gl_FragColor = texture2D( tEquirect, sampleUV ); 30 | 31 | #include 32 | #include 33 | 34 | } 35 | `; 36 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/InstancedBufferGeometry.js: -------------------------------------------------------------------------------- 1 | import { BufferGeometry } from './BufferGeometry.js'; 2 | 3 | class InstancedBufferGeometry extends BufferGeometry { 4 | 5 | constructor() { 6 | 7 | super(); 8 | 9 | this.isInstancedBufferGeometry = true; 10 | 11 | this.type = 'InstancedBufferGeometry'; 12 | this.instanceCount = Infinity; 13 | 14 | } 15 | 16 | copy( source ) { 17 | 18 | super.copy( source ); 19 | 20 | this.instanceCount = source.instanceCount; 21 | 22 | return this; 23 | 24 | } 25 | 26 | toJSON() { 27 | 28 | const data = super.toJSON(); 29 | 30 | data.instanceCount = this.instanceCount; 31 | 32 | data.isInstancedBufferGeometry = true; 33 | 34 | return data; 35 | 36 | } 37 | 38 | } 39 | 40 | export { InstancedBufferGeometry }; 41 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/TetrahedronGeometry.js: -------------------------------------------------------------------------------- 1 | import { PolyhedronGeometry } from './PolyhedronGeometry.js'; 2 | 3 | class TetrahedronGeometry extends PolyhedronGeometry { 4 | 5 | constructor( radius = 1, detail = 0 ) { 6 | 7 | const vertices = [ 8 | 1, 1, 1, - 1, - 1, 1, - 1, 1, - 1, 1, - 1, - 1 9 | ]; 10 | 11 | const indices = [ 12 | 2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1 13 | ]; 14 | 15 | super( vertices, indices, radius, detail ); 16 | 17 | this.type = 'TetrahedronGeometry'; 18 | 19 | this.parameters = { 20 | radius: radius, 21 | detail: detail 22 | }; 23 | 24 | } 25 | 26 | static fromJSON( data ) { 27 | 28 | return new TetrahedronGeometry( data.radius, data.detail ); 29 | 30 | } 31 | 32 | } 33 | 34 | export { TetrahedronGeometry }; 35 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/HemisphereLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { Color } from '../math/Color.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | class HemisphereLight extends Light { 6 | 7 | constructor( skyColor, groundColor, intensity ) { 8 | 9 | super( skyColor, intensity ); 10 | 11 | this.isHemisphereLight = true; 12 | 13 | this.type = 'HemisphereLight'; 14 | 15 | this.position.copy( Object3D.DEFAULT_UP ); 16 | this.updateMatrix(); 17 | 18 | this.groundColor = new Color( groundColor ); 19 | 20 | } 21 | 22 | copy( source, recursive ) { 23 | 24 | super.copy( source, recursive ); 25 | 26 | this.groundColor.copy( source.groundColor ); 27 | 28 | return this; 29 | 30 | } 31 | 32 | } 33 | 34 | export { HemisphereLight }; 35 | -------------------------------------------------------------------------------- /fixtures/threejs_src/audio/AudioAnalyser.js: -------------------------------------------------------------------------------- 1 | class AudioAnalyser { 2 | 3 | constructor( audio, fftSize = 2048 ) { 4 | 5 | this.analyser = audio.context.createAnalyser(); 6 | this.analyser.fftSize = fftSize; 7 | 8 | this.data = new Uint8Array( this.analyser.frequencyBinCount ); 9 | 10 | audio.getOutput().connect( this.analyser ); 11 | 12 | } 13 | 14 | 15 | getFrequencyData() { 16 | 17 | this.analyser.getByteFrequencyData( this.data ); 18 | 19 | return this.data; 20 | 21 | } 22 | 23 | getAverageFrequency() { 24 | 25 | let value = 0; 26 | const data = this.getFrequencyData(); 27 | 28 | for ( let i = 0; i < data.length; i ++ ) { 29 | 30 | value += data[ i ]; 31 | 32 | } 33 | 34 | return value / data.length; 35 | 36 | } 37 | 38 | } 39 | 40 | export { AudioAnalyser }; 41 | -------------------------------------------------------------------------------- /examples/source_map.rs: -------------------------------------------------------------------------------- 1 | use string_wizard::{MagicString, SourceMapOptions, UpdateOptions}; 2 | 3 | fn main() { 4 | let demo = "
\n hello, world\n
"; 5 | let mut s = MagicString::new(demo); 6 | 7 | let update_options = UpdateOptions { keep_original: true, ..Default::default() }; 8 | s.prepend("import React from 'react';\n") 9 | .update_with(1, 2, "v", update_options.clone()) 10 | .update_with(3, 4, "d", update_options.clone()) 11 | .update_with(demo.len() - 4, demo.len() - 1, "h1", update_options.clone()); 12 | 13 | let sm = s.source_map(SourceMapOptions { include_content: true, ..Default::default() }); 14 | 15 | std::fs::write("./demo.map.json", sm.to_json_string()).unwrap(); 16 | std::fs::write("./demo.jsx", s.to_string()).unwrap(); 17 | 18 | println!("{:#?}", s.to_string()); 19 | } 20 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/CubeTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | import { CubeReflectionMapping } from '../constants.js'; 3 | 4 | class CubeTexture extends Texture { 5 | 6 | constructor( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace ) { 7 | 8 | images = images !== undefined ? images : []; 9 | mapping = mapping !== undefined ? mapping : CubeReflectionMapping; 10 | 11 | super( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace ); 12 | 13 | this.isCubeTexture = true; 14 | 15 | this.flipY = false; 16 | 17 | } 18 | 19 | get images() { 20 | 21 | return this.image; 22 | 23 | } 24 | 25 | set images( value ) { 26 | 27 | this.image = value; 28 | 29 | } 30 | 31 | } 32 | 33 | export { CubeTexture }; 34 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLProperties.js: -------------------------------------------------------------------------------- 1 | function WebGLProperties() { 2 | 3 | let properties = new WeakMap(); 4 | 5 | function get( object ) { 6 | 7 | let map = properties.get( object ); 8 | 9 | if ( map === undefined ) { 10 | 11 | map = {}; 12 | properties.set( object, map ); 13 | 14 | } 15 | 16 | return map; 17 | 18 | } 19 | 20 | function remove( object ) { 21 | 22 | properties.delete( object ); 23 | 24 | } 25 | 26 | function update( object, key, value ) { 27 | 28 | properties.get( object )[ key ] = value; 29 | 30 | } 31 | 32 | function dispose() { 33 | 34 | properties = new WeakMap(); 35 | 36 | } 37 | 38 | return { 39 | get: get, 40 | remove: remove, 41 | update: update, 42 | dispose: dispose 43 | }; 44 | 45 | } 46 | 47 | 48 | export { WebGLProperties }; 49 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/InstancedBufferAttribute.js: -------------------------------------------------------------------------------- 1 | import { BufferAttribute } from './BufferAttribute.js'; 2 | 3 | class InstancedBufferAttribute extends BufferAttribute { 4 | 5 | constructor( array, itemSize, normalized, meshPerAttribute = 1 ) { 6 | 7 | super( array, itemSize, normalized ); 8 | 9 | this.isInstancedBufferAttribute = true; 10 | 11 | this.meshPerAttribute = meshPerAttribute; 12 | 13 | } 14 | 15 | copy( source ) { 16 | 17 | super.copy( source ); 18 | 19 | this.meshPerAttribute = source.meshPerAttribute; 20 | 21 | return this; 22 | 23 | } 24 | 25 | toJSON() { 26 | 27 | const data = super.toJSON(); 28 | 29 | data.meshPerAttribute = this.meshPerAttribute; 30 | 31 | data.isInstancedBufferAttribute = true; 32 | 33 | return data; 34 | 35 | } 36 | 37 | } 38 | 39 | export { InstancedBufferAttribute }; 40 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/OctahedronGeometry.js: -------------------------------------------------------------------------------- 1 | import { PolyhedronGeometry } from './PolyhedronGeometry.js'; 2 | 3 | class OctahedronGeometry extends PolyhedronGeometry { 4 | 5 | constructor( radius = 1, detail = 0 ) { 6 | 7 | const vertices = [ 8 | 1, 0, 0, - 1, 0, 0, 0, 1, 0, 9 | 0, - 1, 0, 0, 0, 1, 0, 0, - 1 10 | ]; 11 | 12 | const indices = [ 13 | 0, 2, 4, 0, 4, 3, 0, 3, 5, 14 | 0, 5, 2, 1, 2, 5, 1, 5, 3, 15 | 1, 3, 4, 1, 4, 2 16 | ]; 17 | 18 | super( vertices, indices, radius, detail ); 19 | 20 | this.type = 'OctahedronGeometry'; 21 | 22 | this.parameters = { 23 | radius: radius, 24 | detail: detail 25 | }; 26 | 27 | } 28 | 29 | static fromJSON( data ) { 30 | 31 | return new OctahedronGeometry( data.radius, data.detail ); 32 | 33 | } 34 | 35 | } 36 | 37 | export { OctahedronGeometry }; 38 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 3 | 4 | vec4 plane; 5 | 6 | #pragma unroll_loop_start 7 | for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 8 | 9 | plane = clippingPlanes[ i ]; 10 | if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; 11 | 12 | } 13 | #pragma unroll_loop_end 14 | 15 | #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 16 | 17 | bool clipped = true; 18 | 19 | #pragma unroll_loop_start 20 | for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 21 | 22 | plane = clippingPlanes[ i ]; 23 | clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; 24 | 25 | } 26 | #pragma unroll_loop_end 27 | 28 | if ( clipped ) discard; 29 | 30 | #endif 31 | 32 | #endif 33 | `; 34 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | #ifdef USE_NORMALMAP_OBJECTSPACE 4 | 5 | normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals 6 | 7 | #ifdef FLIP_SIDED 8 | 9 | normal = - normal; 10 | 11 | #endif 12 | 13 | #ifdef DOUBLE_SIDED 14 | 15 | normal = normal * faceDirection; 16 | 17 | #endif 18 | 19 | normal = normalize( normalMatrix * normal ); 20 | 21 | #elif defined( USE_NORMALMAP_TANGENTSPACE ) 22 | 23 | vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; 24 | mapN.xy *= normalScale; 25 | 26 | normal = normalize( tbn * mapN ); 27 | 28 | #elif defined( USE_BUMPMAP ) 29 | 30 | normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); 31 | 32 | #endif 33 | `; 34 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/cube.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | varying vec3 vWorldDirection; 3 | 4 | #include 5 | 6 | void main() { 7 | 8 | vWorldDirection = transformDirection( position, modelMatrix ); 9 | 10 | #include 11 | #include 12 | 13 | gl_Position.z = gl_Position.w; // set z to camera.far 14 | 15 | } 16 | `; 17 | 18 | export const fragment = /* glsl */` 19 | uniform samplerCube tCube; 20 | uniform float tFlip; 21 | uniform float opacity; 22 | 23 | varying vec3 vWorldDirection; 24 | 25 | void main() { 26 | 27 | vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); 28 | 29 | gl_FragColor = texColor; 30 | gl_FragColor.a *= opacity; 31 | 32 | #include 33 | #include 34 | 35 | } 36 | `; 37 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/CompressedTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | 3 | class CompressedTexture extends Texture { 4 | 5 | constructor( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, colorSpace ) { 6 | 7 | super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, colorSpace ); 8 | 9 | this.isCompressedTexture = true; 10 | 11 | this.image = { width: width, height: height }; 12 | this.mipmaps = mipmaps; 13 | 14 | // no flipping for cube textures 15 | // (also flipping doesn't work for compressed textures ) 16 | 17 | this.flipY = false; 18 | 19 | // can't generate mipmaps for compressed textures 20 | // mips must be embedded in DDS files 21 | 22 | this.generateMipmaps = false; 23 | 24 | } 25 | 26 | } 27 | 28 | export { CompressedTexture }; 29 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | #ifdef ENV_WORLDPOS 5 | 6 | vWorldPosition = worldPosition.xyz; 7 | 8 | #else 9 | 10 | vec3 cameraToVertex; 11 | 12 | if ( isOrthographic ) { 13 | 14 | cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 15 | 16 | } else { 17 | 18 | cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); 19 | 20 | } 21 | 22 | vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 23 | 24 | #ifdef ENVMAP_MODE_REFLECTION 25 | 26 | vReflect = reflect( cameraToVertex, worldNormal ); 27 | 28 | #else 29 | 30 | vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); 31 | 32 | #endif 33 | 34 | #endif 35 | 36 | #endif 37 | `; 38 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/Layers.js: -------------------------------------------------------------------------------- 1 | class Layers { 2 | 3 | constructor() { 4 | 5 | this.mask = 1 | 0; 6 | 7 | } 8 | 9 | set( channel ) { 10 | 11 | this.mask = ( 1 << channel | 0 ) >>> 0; 12 | 13 | } 14 | 15 | enable( channel ) { 16 | 17 | this.mask |= 1 << channel | 0; 18 | 19 | } 20 | 21 | enableAll() { 22 | 23 | this.mask = 0xffffffff | 0; 24 | 25 | } 26 | 27 | toggle( channel ) { 28 | 29 | this.mask ^= 1 << channel | 0; 30 | 31 | } 32 | 33 | disable( channel ) { 34 | 35 | this.mask &= ~ ( 1 << channel | 0 ); 36 | 37 | } 38 | 39 | disableAll() { 40 | 41 | this.mask = 0; 42 | 43 | } 44 | 45 | test( layers ) { 46 | 47 | return ( this.mask & layers.mask ) !== 0; 48 | 49 | } 50 | 51 | isEnabled( channel ) { 52 | 53 | return ( this.mask & ( 1 << channel | 0 ) ) !== 0; 54 | 55 | } 56 | 57 | } 58 | 59 | 60 | export { Layers }; 61 | -------------------------------------------------------------------------------- /fixtures/threejs_src/animation/tracks/BooleanKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { InterpolateDiscrete } from '../../constants.js'; 2 | import { KeyframeTrack } from '../KeyframeTrack.js'; 3 | 4 | /** 5 | * A Track of Boolean keyframe values. 6 | */ 7 | class BooleanKeyframeTrack extends KeyframeTrack {} 8 | 9 | BooleanKeyframeTrack.prototype.ValueTypeName = 'bool'; 10 | BooleanKeyframeTrack.prototype.ValueBufferType = Array; 11 | BooleanKeyframeTrack.prototype.DefaultInterpolation = InterpolateDiscrete; 12 | BooleanKeyframeTrack.prototype.InterpolantFactoryMethodLinear = undefined; 13 | BooleanKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; 14 | 15 | // Note: Actually this track could have a optimized / compressed 16 | // representation of a single value and a custom interpolant that 17 | // computes "firstValue ^ isOdd( index )". 18 | 19 | export { BooleanKeyframeTrack }; 20 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/TextureLoader.js: -------------------------------------------------------------------------------- 1 | import { ImageLoader } from './ImageLoader.js'; 2 | import { Texture } from '../textures/Texture.js'; 3 | import { Loader } from './Loader.js'; 4 | 5 | class TextureLoader extends Loader { 6 | 7 | constructor( manager ) { 8 | 9 | super( manager ); 10 | 11 | } 12 | 13 | load( url, onLoad, onProgress, onError ) { 14 | 15 | const texture = new Texture(); 16 | 17 | const loader = new ImageLoader( this.manager ); 18 | loader.setCrossOrigin( this.crossOrigin ); 19 | loader.setPath( this.path ); 20 | 21 | loader.load( url, function ( image ) { 22 | 23 | texture.image = image; 24 | texture.needsUpdate = true; 25 | 26 | if ( onLoad !== undefined ) { 27 | 28 | onLoad( texture ); 29 | 30 | } 31 | 32 | }, onProgress, onError ); 33 | 34 | return texture; 35 | 36 | } 37 | 38 | } 39 | 40 | 41 | export { TextureLoader }; 42 | -------------------------------------------------------------------------------- /fixtures/threejs_src/animation/tracks/QuaternionKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { InterpolateLinear } from '../../constants.js'; 2 | import { KeyframeTrack } from '../KeyframeTrack.js'; 3 | import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant.js'; 4 | 5 | /** 6 | * A Track of quaternion keyframe values. 7 | */ 8 | class QuaternionKeyframeTrack extends KeyframeTrack { 9 | 10 | InterpolantFactoryMethodLinear( result ) { 11 | 12 | return new QuaternionLinearInterpolant( this.times, this.values, this.getValueSize(), result ); 13 | 14 | } 15 | 16 | } 17 | 18 | QuaternionKeyframeTrack.prototype.ValueTypeName = 'quaternion'; 19 | // ValueBufferType is inherited 20 | QuaternionKeyframeTrack.prototype.DefaultInterpolation = InterpolateLinear; 21 | QuaternionKeyframeTrack.prototype.InterpolantFactoryMethodSmooth = undefined; 22 | 23 | export { QuaternionKeyframeTrack }; 24 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/Geometries.js: -------------------------------------------------------------------------------- 1 | export * from './BoxGeometry.js'; 2 | export * from './CapsuleGeometry.js'; 3 | export * from './CircleGeometry.js'; 4 | export * from './ConeGeometry.js'; 5 | export * from './CylinderGeometry.js'; 6 | export * from './DodecahedronGeometry.js'; 7 | export * from './EdgesGeometry.js'; 8 | export * from './ExtrudeGeometry.js'; 9 | export * from './IcosahedronGeometry.js'; 10 | export * from './LatheGeometry.js'; 11 | export * from './OctahedronGeometry.js'; 12 | export * from './PlaneGeometry.js'; 13 | export * from './PolyhedronGeometry.js'; 14 | export * from './RingGeometry.js'; 15 | export * from './ShapeGeometry.js'; 16 | export * from './SphereGeometry.js'; 17 | export * from './TetrahedronGeometry.js'; 18 | export * from './TorusGeometry.js'; 19 | export * from './TorusKnotGeometry.js'; 20 | export * from './TubeGeometry.js'; 21 | export * from './WireframeGeometry.js'; 22 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/LightProbe.js: -------------------------------------------------------------------------------- 1 | import { SphericalHarmonics3 } from '../math/SphericalHarmonics3.js'; 2 | import { Light } from './Light.js'; 3 | 4 | class LightProbe extends Light { 5 | 6 | constructor( sh = new SphericalHarmonics3(), intensity = 1 ) { 7 | 8 | super( undefined, intensity ); 9 | 10 | this.isLightProbe = true; 11 | 12 | this.sh = sh; 13 | 14 | } 15 | 16 | copy( source ) { 17 | 18 | super.copy( source ); 19 | 20 | this.sh.copy( source.sh ); 21 | 22 | return this; 23 | 24 | } 25 | 26 | fromJSON( json ) { 27 | 28 | this.intensity = json.intensity; // TODO: Move this bit to Light.fromJSON(); 29 | this.sh.fromArray( json.sh ); 30 | 31 | return this; 32 | 33 | } 34 | 35 | toJSON( meta ) { 36 | 37 | const data = super.toJSON( meta ); 38 | 39 | data.object.sh = this.sh.toArray(); 40 | 41 | return data; 42 | 43 | } 44 | 45 | } 46 | 47 | export { LightProbe }; 48 | -------------------------------------------------------------------------------- /fixtures/threejs_src/math/interpolants/LinearInterpolant.js: -------------------------------------------------------------------------------- 1 | import { Interpolant } from '../Interpolant.js'; 2 | 3 | class LinearInterpolant extends Interpolant { 4 | 5 | constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { 6 | 7 | super( parameterPositions, sampleValues, sampleSize, resultBuffer ); 8 | 9 | } 10 | 11 | interpolate_( i1, t0, t, t1 ) { 12 | 13 | const result = this.resultBuffer, 14 | values = this.sampleValues, 15 | stride = this.valueSize, 16 | 17 | offset1 = i1 * stride, 18 | offset0 = offset1 - stride, 19 | 20 | weight1 = ( t - t0 ) / ( t1 - t0 ), 21 | weight0 = 1 - weight1; 22 | 23 | for ( let i = 0; i !== stride; ++ i ) { 24 | 25 | result[ i ] = 26 | values[ offset0 + i ] * weight0 + 27 | values[ offset1 + i ] * weight1; 28 | 29 | } 30 | 31 | return result; 32 | 33 | } 34 | 35 | } 36 | 37 | 38 | export { LinearInterpolant }; 39 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/DirectionalLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { DirectionalLightShadow } from './DirectionalLightShadow.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | class DirectionalLight extends Light { 6 | 7 | constructor( color, intensity ) { 8 | 9 | super( color, intensity ); 10 | 11 | this.isDirectionalLight = true; 12 | 13 | this.type = 'DirectionalLight'; 14 | 15 | this.position.copy( Object3D.DEFAULT_UP ); 16 | this.updateMatrix(); 17 | 18 | this.target = new Object3D(); 19 | 20 | this.shadow = new DirectionalLightShadow(); 21 | 22 | } 23 | 24 | dispose() { 25 | 26 | this.shadow.dispose(); 27 | 28 | } 29 | 30 | copy( source ) { 31 | 32 | super.copy( source ); 33 | 34 | this.target = source.target.clone(); 35 | this.shadow = source.shadow.clone(); 36 | 37 | return this; 38 | 39 | } 40 | 41 | } 42 | 43 | export { DirectionalLight }; 44 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 transformedNormal = objectNormal; 3 | 4 | #ifdef USE_INSTANCING 5 | 6 | // this is in lieu of a per-instance normal-matrix 7 | // shear transforms in the instance matrix are not supported 8 | 9 | mat3 m = mat3( instanceMatrix ); 10 | 11 | transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) ); 12 | 13 | transformedNormal = m * transformedNormal; 14 | 15 | #endif 16 | 17 | transformedNormal = normalMatrix * transformedNormal; 18 | 19 | #ifdef FLIP_SIDED 20 | 21 | transformedNormal = - transformedNormal; 22 | 23 | #endif 24 | 25 | #ifdef USE_TANGENT 26 | 27 | vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz; 28 | 29 | #ifdef FLIP_SIDED 30 | 31 | transformedTangent = - transformedTangent; 32 | 33 | #endif 34 | 35 | #endif 36 | `; 37 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/MeshDistanceMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | 3 | class MeshDistanceMaterial extends Material { 4 | 5 | constructor( parameters ) { 6 | 7 | super(); 8 | 9 | this.isMeshDistanceMaterial = true; 10 | 11 | this.type = 'MeshDistanceMaterial'; 12 | 13 | this.map = null; 14 | 15 | this.alphaMap = null; 16 | 17 | this.displacementMap = null; 18 | this.displacementScale = 1; 19 | this.displacementBias = 0; 20 | 21 | this.setValues( parameters ); 22 | 23 | } 24 | 25 | copy( source ) { 26 | 27 | super.copy( source ); 28 | 29 | this.map = source.map; 30 | 31 | this.alphaMap = source.alphaMap; 32 | 33 | this.displacementMap = source.displacementMap; 34 | this.displacementScale = source.displacementScale; 35 | this.displacementBias = source.displacementBias; 36 | 37 | return this; 38 | 39 | } 40 | 41 | } 42 | 43 | export { MeshDistanceMaterial }; 44 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/CapsuleGeometry.js: -------------------------------------------------------------------------------- 1 | import { Path } from '../extras/core/Path.js'; 2 | import { LatheGeometry } from './LatheGeometry.js'; 3 | 4 | class CapsuleGeometry extends LatheGeometry { 5 | 6 | constructor( radius = 1, length = 1, capSegments = 4, radialSegments = 8 ) { 7 | 8 | const path = new Path(); 9 | path.absarc( 0, - length / 2, radius, Math.PI * 1.5, 0 ); 10 | path.absarc( 0, length / 2, radius, 0, Math.PI * 0.5 ); 11 | 12 | super( path.getPoints( capSegments ), radialSegments ); 13 | 14 | this.type = 'CapsuleGeometry'; 15 | 16 | this.parameters = { 17 | radius: radius, 18 | length: length, 19 | capSegments: capSegments, 20 | radialSegments: radialSegments, 21 | }; 22 | 23 | } 24 | 25 | static fromJSON( data ) { 26 | 27 | return new CapsuleGeometry( data.radius, data.length, data.capSegments, data.radialSegments ); 28 | 29 | } 30 | 31 | } 32 | 33 | export { CapsuleGeometry }; 34 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/ConeGeometry.js: -------------------------------------------------------------------------------- 1 | import { CylinderGeometry } from './CylinderGeometry.js'; 2 | 3 | class ConeGeometry extends CylinderGeometry { 4 | 5 | constructor( radius = 1, height = 1, radialSegments = 32, heightSegments = 1, openEnded = false, thetaStart = 0, thetaLength = Math.PI * 2 ) { 6 | 7 | super( 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ); 8 | 9 | this.type = 'ConeGeometry'; 10 | 11 | this.parameters = { 12 | radius: radius, 13 | height: height, 14 | radialSegments: radialSegments, 15 | heightSegments: heightSegments, 16 | openEnded: openEnded, 17 | thetaStart: thetaStart, 18 | thetaLength: thetaLength 19 | }; 20 | 21 | } 22 | 23 | static fromJSON( data ) { 24 | 25 | return new ConeGeometry( data.radius, data.height, data.radialSegments, data.heightSegments, data.openEnded, data.thetaStart, data.thetaLength ); 26 | 27 | } 28 | 29 | } 30 | 31 | export { ConeGeometry }; 32 | -------------------------------------------------------------------------------- /src/magic_string/prepend.rs: -------------------------------------------------------------------------------- 1 | use crate::CowStr; 2 | 3 | use super::MagicString; 4 | 5 | impl<'text> MagicString<'text> { 6 | pub fn prepend(&mut self, source: impl Into>) -> &mut Self { 7 | self.prepend_intro(source.into()); 8 | self 9 | } 10 | 11 | pub fn prepend_left( 12 | &mut self, 13 | text_index: usize, 14 | content: impl Into>, 15 | ) -> &mut Self { 16 | match self.by_end_mut(text_index) { 17 | Some(chunk) => chunk.prepend_outro(content.into()), 18 | None => self.prepend_intro(content.into()), 19 | } 20 | self 21 | } 22 | 23 | pub fn prepend_right( 24 | &mut self, 25 | text_index: usize, 26 | content: impl Into>, 27 | ) -> &mut Self { 28 | match self.by_start_mut(text_index) { 29 | Some(chunk) => { 30 | chunk.prepend_intro(content.into()); 31 | } 32 | None => self.prepend_outro(content.into()), 33 | } 34 | self 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/PointsMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | class PointsMaterial extends Material { 5 | 6 | constructor( parameters ) { 7 | 8 | super(); 9 | 10 | this.isPointsMaterial = true; 11 | 12 | this.type = 'PointsMaterial'; 13 | 14 | this.color = new Color( 0xffffff ); 15 | 16 | this.map = null; 17 | 18 | this.alphaMap = null; 19 | 20 | this.size = 1; 21 | this.sizeAttenuation = true; 22 | 23 | this.fog = true; 24 | 25 | this.setValues( parameters ); 26 | 27 | } 28 | 29 | copy( source ) { 30 | 31 | super.copy( source ); 32 | 33 | this.color.copy( source.color ); 34 | 35 | this.map = source.map; 36 | 37 | this.alphaMap = source.alphaMap; 38 | 39 | this.size = source.size; 40 | this.sizeAttenuation = source.sizeAttenuation; 41 | 42 | this.fog = source.fog; 43 | 44 | return this; 45 | 46 | } 47 | 48 | } 49 | 50 | export { PointsMaterial }; 51 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/Data3DTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | import { ClampToEdgeWrapping, NearestFilter } from '../constants.js'; 3 | 4 | class Data3DTexture extends Texture { 5 | 6 | constructor( data = null, width = 1, height = 1, depth = 1 ) { 7 | 8 | // We're going to add .setXXX() methods for setting properties later. 9 | // Users can still set in DataTexture3D directly. 10 | // 11 | // const texture = new THREE.DataTexture3D( data, width, height, depth ); 12 | // texture.anisotropy = 16; 13 | // 14 | // See #14839 15 | 16 | super( null ); 17 | 18 | this.isData3DTexture = true; 19 | 20 | this.image = { data, width, height, depth }; 21 | 22 | this.magFilter = NearestFilter; 23 | this.minFilter = NearestFilter; 24 | 25 | this.wrapR = ClampToEdgeWrapping; 26 | 27 | this.generateMipmaps = false; 28 | this.flipY = false; 29 | this.unpackAlignment = 1; 30 | 31 | } 32 | 33 | } 34 | 35 | export { Data3DTexture }; 36 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/LineBasicMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | class LineBasicMaterial extends Material { 5 | 6 | constructor( parameters ) { 7 | 8 | super(); 9 | 10 | this.isLineBasicMaterial = true; 11 | 12 | this.type = 'LineBasicMaterial'; 13 | 14 | this.color = new Color( 0xffffff ); 15 | 16 | this.map = null; 17 | 18 | this.linewidth = 1; 19 | this.linecap = 'round'; 20 | this.linejoin = 'round'; 21 | 22 | this.fog = true; 23 | 24 | this.setValues( parameters ); 25 | 26 | } 27 | 28 | 29 | copy( source ) { 30 | 31 | super.copy( source ); 32 | 33 | this.color.copy( source.color ); 34 | 35 | this.map = source.map; 36 | 37 | this.linewidth = source.linewidth; 38 | this.linecap = source.linecap; 39 | this.linejoin = source.linejoin; 40 | 41 | this.fog = source.fog; 42 | 43 | return this; 44 | 45 | } 46 | 47 | } 48 | 49 | export { LineBasicMaterial }; 50 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec3 vViewPosition; 3 | 4 | struct ToonMaterial { 5 | 6 | vec3 diffuseColor; 7 | 8 | }; 9 | 10 | void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 11 | 12 | vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; 13 | 14 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 15 | 16 | } 17 | 18 | void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { 19 | 20 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 21 | 22 | } 23 | 24 | #define RE_Direct RE_Direct_Toon 25 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon 26 | `; 27 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/InstancedInterleavedBuffer.js: -------------------------------------------------------------------------------- 1 | import { InterleavedBuffer } from './InterleavedBuffer.js'; 2 | 3 | class InstancedInterleavedBuffer extends InterleavedBuffer { 4 | 5 | constructor( array, stride, meshPerAttribute = 1 ) { 6 | 7 | super( array, stride ); 8 | 9 | this.isInstancedInterleavedBuffer = true; 10 | 11 | this.meshPerAttribute = meshPerAttribute; 12 | 13 | } 14 | 15 | copy( source ) { 16 | 17 | super.copy( source ); 18 | 19 | this.meshPerAttribute = source.meshPerAttribute; 20 | 21 | return this; 22 | 23 | } 24 | 25 | clone( data ) { 26 | 27 | const ib = super.clone( data ); 28 | 29 | ib.meshPerAttribute = this.meshPerAttribute; 30 | 31 | return ib; 32 | 33 | } 34 | 35 | toJSON( data ) { 36 | 37 | const json = super.toJSON( data ); 38 | 39 | json.isInstancedInterleavedBuffer = true; 40 | json.meshPerAttribute = this.meshPerAttribute; 41 | 42 | return json; 43 | 44 | } 45 | 46 | } 47 | 48 | export { InstancedInterleavedBuffer }; 49 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | uniform mat4 bindMatrix; 5 | uniform mat4 bindMatrixInverse; 6 | 7 | uniform highp sampler2D boneTexture; 8 | uniform int boneTextureSize; 9 | 10 | mat4 getBoneMatrix( const in float i ) { 11 | 12 | float j = i * 4.0; 13 | float x = mod( j, float( boneTextureSize ) ); 14 | float y = floor( j / float( boneTextureSize ) ); 15 | 16 | float dx = 1.0 / float( boneTextureSize ); 17 | float dy = 1.0 / float( boneTextureSize ); 18 | 19 | y = dy * ( y + 0.5 ); 20 | 21 | vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); 22 | vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); 23 | vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); 24 | vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); 25 | 26 | mat4 bone = mat4( v1, v2, v3, v4 ); 27 | 28 | return bone; 29 | 30 | } 31 | 32 | #endif 33 | `; 34 | -------------------------------------------------------------------------------- /fixtures/threejs_src/math/interpolants/QuaternionLinearInterpolant.js: -------------------------------------------------------------------------------- 1 | import { Interpolant } from '../Interpolant.js'; 2 | import { Quaternion } from '../Quaternion.js'; 3 | 4 | /** 5 | * Spherical linear unit quaternion interpolant. 6 | */ 7 | 8 | class QuaternionLinearInterpolant extends Interpolant { 9 | 10 | constructor( parameterPositions, sampleValues, sampleSize, resultBuffer ) { 11 | 12 | super( parameterPositions, sampleValues, sampleSize, resultBuffer ); 13 | 14 | } 15 | 16 | interpolate_( i1, t0, t, t1 ) { 17 | 18 | const result = this.resultBuffer, 19 | values = this.sampleValues, 20 | stride = this.valueSize, 21 | 22 | alpha = ( t - t0 ) / ( t1 - t0 ); 23 | 24 | let offset = i1 * stride; 25 | 26 | for ( let end = offset + stride; offset !== end; offset += 4 ) { 27 | 28 | Quaternion.slerpFlat( result, 0, values, offset - stride, values, offset, alpha ); 29 | 30 | } 31 | 32 | return result; 33 | 34 | } 35 | 36 | } 37 | 38 | 39 | export { QuaternionLinearInterpolant }; 40 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE ) 3 | 4 | // morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value: 5 | // When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence) 6 | // When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting 7 | vColor *= morphTargetBaseInfluence; 8 | 9 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 10 | 11 | #if defined( USE_COLOR_ALPHA ) 12 | 13 | if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; 14 | 15 | #elif defined( USE_COLOR ) 16 | 17 | if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; 18 | 19 | #endif 20 | 21 | } 22 | 23 | #endif 24 | `; 25 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/GLBufferAttribute.js: -------------------------------------------------------------------------------- 1 | class GLBufferAttribute { 2 | 3 | constructor( buffer, type, itemSize, elementSize, count ) { 4 | 5 | this.isGLBufferAttribute = true; 6 | 7 | this.name = ''; 8 | 9 | this.buffer = buffer; 10 | this.type = type; 11 | this.itemSize = itemSize; 12 | this.elementSize = elementSize; 13 | this.count = count; 14 | 15 | this.version = 0; 16 | 17 | } 18 | 19 | set needsUpdate( value ) { 20 | 21 | if ( value === true ) this.version ++; 22 | 23 | } 24 | 25 | setBuffer( buffer ) { 26 | 27 | this.buffer = buffer; 28 | 29 | return this; 30 | 31 | } 32 | 33 | setType( type, elementSize ) { 34 | 35 | this.type = type; 36 | this.elementSize = elementSize; 37 | 38 | return this; 39 | 40 | } 41 | 42 | setItemSize( itemSize ) { 43 | 44 | this.itemSize = itemSize; 45 | 46 | return this; 47 | 48 | } 49 | 50 | setCount( count ) { 51 | 52 | this.count = count; 53 | 54 | return this; 55 | 56 | } 57 | 58 | } 59 | 60 | export { GLBufferAttribute }; 61 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/bsdfs.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | float G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) { 4 | 5 | // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v) 6 | return 0.25; 7 | 8 | } 9 | 10 | float D_BlinnPhong( const in float shininess, const in float dotNH ) { 11 | 12 | return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess ); 13 | 14 | } 15 | 16 | vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) { 17 | 18 | vec3 halfDir = normalize( lightDir + viewDir ); 19 | 20 | float dotNH = saturate( dot( normal, halfDir ) ); 21 | float dotVH = saturate( dot( viewDir, halfDir ) ); 22 | 23 | vec3 F = F_Schlick( specularColor, 1.0, dotVH ); 24 | 25 | float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ ); 26 | 27 | float D = D_BlinnPhong( shininess, dotNH ); 28 | 29 | return F * ( G * D ); 30 | 31 | } // validated 32 | 33 | `; 34 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/SpriteMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | class SpriteMaterial extends Material { 5 | 6 | constructor( parameters ) { 7 | 8 | super(); 9 | 10 | this.isSpriteMaterial = true; 11 | 12 | this.type = 'SpriteMaterial'; 13 | 14 | this.color = new Color( 0xffffff ); 15 | 16 | this.map = null; 17 | 18 | this.alphaMap = null; 19 | 20 | this.rotation = 0; 21 | 22 | this.sizeAttenuation = true; 23 | 24 | this.transparent = true; 25 | 26 | this.fog = true; 27 | 28 | this.setValues( parameters ); 29 | 30 | } 31 | 32 | copy( source ) { 33 | 34 | super.copy( source ); 35 | 36 | this.color.copy( source.color ); 37 | 38 | this.map = source.map; 39 | 40 | this.alphaMap = source.alphaMap; 41 | 42 | this.rotation = source.rotation; 43 | 44 | this.sizeAttenuation = source.sizeAttenuation; 45 | 46 | this.fog = source.fog; 47 | 48 | return this; 49 | 50 | } 51 | 52 | } 53 | 54 | export { SpriteMaterial }; 55 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLAnimation.js: -------------------------------------------------------------------------------- 1 | function WebGLAnimation() { 2 | 3 | let context = null; 4 | let isAnimating = false; 5 | let animationLoop = null; 6 | let requestId = null; 7 | 8 | function onAnimationFrame( time, frame ) { 9 | 10 | animationLoop( time, frame ); 11 | 12 | requestId = context.requestAnimationFrame( onAnimationFrame ); 13 | 14 | } 15 | 16 | return { 17 | 18 | start: function () { 19 | 20 | if ( isAnimating === true ) return; 21 | if ( animationLoop === null ) return; 22 | 23 | requestId = context.requestAnimationFrame( onAnimationFrame ); 24 | 25 | isAnimating = true; 26 | 27 | }, 28 | 29 | stop: function () { 30 | 31 | context.cancelAnimationFrame( requestId ); 32 | 33 | isAnimating = false; 34 | 35 | }, 36 | 37 | setAnimationLoop: function ( callback ) { 38 | 39 | animationLoop = callback; 40 | 41 | }, 42 | 43 | setContext: function ( value ) { 44 | 45 | context = value; 46 | 47 | } 48 | 49 | }; 50 | 51 | } 52 | 53 | export { WebGLAnimation }; 54 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/background.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | varying vec2 vUv; 3 | uniform mat3 uvTransform; 4 | 5 | void main() { 6 | 7 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 8 | 9 | gl_Position = vec4( position.xy, 1.0, 1.0 ); 10 | 11 | } 12 | `; 13 | 14 | export const fragment = /* glsl */` 15 | uniform sampler2D t2D; 16 | uniform float backgroundIntensity; 17 | 18 | varying vec2 vUv; 19 | 20 | void main() { 21 | 22 | vec4 texColor = texture2D( t2D, vUv ); 23 | 24 | #ifdef DECODE_VIDEO_TEXTURE 25 | 26 | // use inline sRGB decode until browsers properly support SRGB8_APLHA8 with video textures 27 | 28 | texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); 29 | 30 | #endif 31 | 32 | texColor.rgb *= backgroundIntensity; 33 | 34 | gl_FragColor = texColor; 35 | 36 | #include 37 | #include 38 | 39 | } 40 | `; 41 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec3 vViewPosition; 3 | 4 | struct LambertMaterial { 5 | 6 | vec3 diffuseColor; 7 | float specularStrength; 8 | 9 | }; 10 | 11 | void RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 12 | 13 | float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); 14 | vec3 irradiance = dotNL * directLight.color; 15 | 16 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 17 | 18 | } 19 | 20 | void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { 21 | 22 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 23 | 24 | } 25 | 26 | #define RE_Direct RE_Direct_Lambert 27 | #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert 28 | `; 29 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MORPHTARGETS 3 | 4 | uniform float morphTargetBaseInfluence; 5 | 6 | #ifdef MORPHTARGETS_TEXTURE 7 | 8 | uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; 9 | uniform sampler2DArray morphTargetsTexture; 10 | uniform ivec2 morphTargetsTextureSize; 11 | 12 | vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { 13 | 14 | int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; 15 | int y = texelIndex / morphTargetsTextureSize.x; 16 | int x = texelIndex - y * morphTargetsTextureSize.x; 17 | 18 | ivec3 morphUV = ivec3( x, y, morphTargetIndex ); 19 | return texelFetch( morphTargetsTexture, morphUV, 0 ); 20 | 21 | } 22 | 23 | #else 24 | 25 | #ifndef USE_MORPHNORMALS 26 | 27 | uniform float morphTargetInfluences[ 8 ]; 28 | 29 | #else 30 | 31 | uniform float morphTargetInfluences[ 4 ]; 32 | 33 | #endif 34 | 35 | #endif 36 | 37 | #endif 38 | `; 39 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MORPHNORMALS 3 | 4 | // morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value: 5 | // When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence) 6 | // When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting 7 | objectNormal *= morphTargetBaseInfluence; 8 | 9 | #ifdef MORPHTARGETS_TEXTURE 10 | 11 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 12 | 13 | if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; 14 | 15 | } 16 | 17 | #else 18 | 19 | objectNormal += morphNormal0 * morphTargetInfluences[ 0 ]; 20 | objectNormal += morphNormal1 * morphTargetInfluences[ 1 ]; 21 | objectNormal += morphNormal2 * morphTargetInfluences[ 2 ]; 22 | objectNormal += morphNormal3 * morphTargetInfluences[ 3 ]; 23 | 24 | #endif 25 | 26 | #endif 27 | `; 28 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/IcosahedronGeometry.js: -------------------------------------------------------------------------------- 1 | import { PolyhedronGeometry } from './PolyhedronGeometry.js'; 2 | 3 | class IcosahedronGeometry extends PolyhedronGeometry { 4 | 5 | constructor( radius = 1, detail = 0 ) { 6 | 7 | const t = ( 1 + Math.sqrt( 5 ) ) / 2; 8 | 9 | const vertices = [ 10 | - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0, 11 | 0, - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 12 | t, 0, - 1, t, 0, 1, - t, 0, - 1, - t, 0, 1 13 | ]; 14 | 15 | const indices = [ 16 | 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 17 | 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 18 | 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 19 | 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1 20 | ]; 21 | 22 | super( vertices, indices, radius, detail ); 23 | 24 | this.type = 'IcosahedronGeometry'; 25 | 26 | this.parameters = { 27 | radius: radius, 28 | detail: detail 29 | }; 30 | 31 | } 32 | 33 | static fromJSON( data ) { 34 | 35 | return new IcosahedronGeometry( data.radius, data.detail ); 36 | 37 | } 38 | 39 | } 40 | 41 | 42 | export { IcosahedronGeometry }; 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Yunfei He 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( RE_IndirectDiffuse ) 3 | 4 | #ifdef USE_LIGHTMAP 5 | 6 | vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); 7 | vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; 8 | 9 | irradiance += lightMapIrradiance; 10 | 11 | #endif 12 | 13 | #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) 14 | 15 | iblIrradiance += getIBLIrradiance( geometry.normal ); 16 | 17 | #endif 18 | 19 | #endif 20 | 21 | #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) 22 | 23 | #ifdef USE_ANISOTROPY 24 | 25 | radiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy ); 26 | 27 | #else 28 | 29 | radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness ); 30 | 31 | #endif 32 | 33 | #ifdef USE_CLEARCOAT 34 | 35 | clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness ); 36 | 37 | #endif 38 | 39 | #endif 40 | `; 41 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/SpotLightShadow.js: -------------------------------------------------------------------------------- 1 | import { LightShadow } from './LightShadow.js'; 2 | import * as MathUtils from '../math/MathUtils.js'; 3 | import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; 4 | 5 | class SpotLightShadow extends LightShadow { 6 | 7 | constructor() { 8 | 9 | super( new PerspectiveCamera( 50, 1, 0.5, 500 ) ); 10 | 11 | this.isSpotLightShadow = true; 12 | 13 | this.focus = 1; 14 | 15 | } 16 | 17 | updateMatrices( light ) { 18 | 19 | const camera = this.camera; 20 | 21 | const fov = MathUtils.RAD2DEG * 2 * light.angle * this.focus; 22 | const aspect = this.mapSize.width / this.mapSize.height; 23 | const far = light.distance || camera.far; 24 | 25 | if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) { 26 | 27 | camera.fov = fov; 28 | camera.aspect = aspect; 29 | camera.far = far; 30 | camera.updateProjectionMatrix(); 31 | 32 | } 33 | 34 | super.updateMatrices( light ); 35 | 36 | } 37 | 38 | copy( source ) { 39 | 40 | super.copy( source ); 41 | 42 | this.focus = source.focus; 43 | 44 | return this; 45 | 46 | } 47 | 48 | } 49 | 50 | export { SpotLightShadow }; 51 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/RectAreaLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | 3 | class RectAreaLight extends Light { 4 | 5 | constructor( color, intensity, width = 10, height = 10 ) { 6 | 7 | super( color, intensity ); 8 | 9 | this.isRectAreaLight = true; 10 | 11 | this.type = 'RectAreaLight'; 12 | 13 | this.width = width; 14 | this.height = height; 15 | 16 | } 17 | 18 | get power() { 19 | 20 | // compute the light's luminous power (in lumens) from its intensity (in nits) 21 | return this.intensity * this.width * this.height * Math.PI; 22 | 23 | } 24 | 25 | set power( power ) { 26 | 27 | // set the light's intensity (in nits) from the desired luminous power (in lumens) 28 | this.intensity = power / ( this.width * this.height * Math.PI ); 29 | 30 | } 31 | 32 | copy( source ) { 33 | 34 | super.copy( source ); 35 | 36 | this.width = source.width; 37 | this.height = source.height; 38 | 39 | return this; 40 | 41 | } 42 | 43 | toJSON( meta ) { 44 | 45 | const data = super.toJSON( meta ); 46 | 47 | data.object.width = this.width; 48 | data.object.height = this.height; 49 | 50 | return data; 51 | 52 | } 53 | 54 | } 55 | 56 | export { RectAreaLight }; 57 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_NORMALMAP 3 | 4 | uniform sampler2D normalMap; 5 | uniform vec2 normalScale; 6 | 7 | #endif 8 | 9 | #ifdef USE_NORMALMAP_OBJECTSPACE 10 | 11 | uniform mat3 normalMatrix; 12 | 13 | #endif 14 | 15 | #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) 16 | 17 | // Normal Mapping Without Precomputed Tangents 18 | // http://www.thetenthplanet.de/archives/1180 19 | 20 | mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { 21 | 22 | vec3 q0 = dFdx( eye_pos.xyz ); 23 | vec3 q1 = dFdy( eye_pos.xyz ); 24 | vec2 st0 = dFdx( uv.st ); 25 | vec2 st1 = dFdy( uv.st ); 26 | 27 | vec3 N = surf_norm; // normalized 28 | 29 | vec3 q1perp = cross( q1, N ); 30 | vec3 q0perp = cross( N, q0 ); 31 | 32 | vec3 T = q1perp * st0.x + q0perp * st1.x; 33 | vec3 B = q1perp * st0.y + q0perp * st1.y; 34 | 35 | float det = max( dot( T, T ), dot( B, B ) ); 36 | float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); 37 | 38 | return mat3( T * scale, B * scale, N ); 39 | 40 | } 41 | 42 | #endif 43 | `; 44 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/Clock.js: -------------------------------------------------------------------------------- 1 | class Clock { 2 | 3 | constructor( autoStart = true ) { 4 | 5 | this.autoStart = autoStart; 6 | 7 | this.startTime = 0; 8 | this.oldTime = 0; 9 | this.elapsedTime = 0; 10 | 11 | this.running = false; 12 | 13 | } 14 | 15 | start() { 16 | 17 | this.startTime = now(); 18 | 19 | this.oldTime = this.startTime; 20 | this.elapsedTime = 0; 21 | this.running = true; 22 | 23 | } 24 | 25 | stop() { 26 | 27 | this.getElapsedTime(); 28 | this.running = false; 29 | this.autoStart = false; 30 | 31 | } 32 | 33 | getElapsedTime() { 34 | 35 | this.getDelta(); 36 | return this.elapsedTime; 37 | 38 | } 39 | 40 | getDelta() { 41 | 42 | let diff = 0; 43 | 44 | if ( this.autoStart && ! this.running ) { 45 | 46 | this.start(); 47 | return 0; 48 | 49 | } 50 | 51 | if ( this.running ) { 52 | 53 | const newTime = now(); 54 | 55 | diff = ( newTime - this.oldTime ) / 1000; 56 | this.oldTime = newTime; 57 | 58 | this.elapsedTime += diff; 59 | 60 | } 61 | 62 | return diff; 63 | 64 | } 65 | 66 | } 67 | 68 | function now() { 69 | 70 | return ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732 71 | 72 | } 73 | 74 | export { Clock }; 75 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/CubeTextureLoader.js: -------------------------------------------------------------------------------- 1 | import { ImageLoader } from './ImageLoader.js'; 2 | import { CubeTexture } from '../textures/CubeTexture.js'; 3 | import { Loader } from './Loader.js'; 4 | import { SRGBColorSpace } from '../constants.js'; 5 | 6 | class CubeTextureLoader extends Loader { 7 | 8 | constructor( manager ) { 9 | 10 | super( manager ); 11 | 12 | } 13 | 14 | load( urls, onLoad, onProgress, onError ) { 15 | 16 | const texture = new CubeTexture(); 17 | texture.colorSpace = SRGBColorSpace; 18 | 19 | const loader = new ImageLoader( this.manager ); 20 | loader.setCrossOrigin( this.crossOrigin ); 21 | loader.setPath( this.path ); 22 | 23 | let loaded = 0; 24 | 25 | function loadTexture( i ) { 26 | 27 | loader.load( urls[ i ], function ( image ) { 28 | 29 | texture.images[ i ] = image; 30 | 31 | loaded ++; 32 | 33 | if ( loaded === 6 ) { 34 | 35 | texture.needsUpdate = true; 36 | 37 | if ( onLoad ) onLoad( texture ); 38 | 39 | } 40 | 41 | }, undefined, onError ); 42 | 43 | } 44 | 45 | for ( let i = 0; i < urls.length; ++ i ) { 46 | 47 | loadTexture( i ); 48 | 49 | } 50 | 51 | return texture; 52 | 53 | } 54 | 55 | } 56 | 57 | 58 | export { CubeTextureLoader }; 59 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/MeshDepthMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { BasicDepthPacking } from '../constants.js'; 3 | 4 | class MeshDepthMaterial extends Material { 5 | 6 | constructor( parameters ) { 7 | 8 | super(); 9 | 10 | this.isMeshDepthMaterial = true; 11 | 12 | this.type = 'MeshDepthMaterial'; 13 | 14 | this.depthPacking = BasicDepthPacking; 15 | 16 | this.map = null; 17 | 18 | this.alphaMap = null; 19 | 20 | this.displacementMap = null; 21 | this.displacementScale = 1; 22 | this.displacementBias = 0; 23 | 24 | this.wireframe = false; 25 | this.wireframeLinewidth = 1; 26 | 27 | this.setValues( parameters ); 28 | 29 | } 30 | 31 | copy( source ) { 32 | 33 | super.copy( source ); 34 | 35 | this.depthPacking = source.depthPacking; 36 | 37 | this.map = source.map; 38 | 39 | this.alphaMap = source.alphaMap; 40 | 41 | this.displacementMap = source.displacementMap; 42 | this.displacementScale = source.displacementScale; 43 | this.displacementBias = source.displacementBias; 44 | 45 | this.wireframe = source.wireframe; 46 | this.wireframeLinewidth = source.wireframeLinewidth; 47 | 48 | return this; 49 | 50 | } 51 | 52 | } 53 | 54 | export { MeshDepthMaterial }; 55 | -------------------------------------------------------------------------------- /fixtures/threejs_src/math/Cylindrical.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system 3 | */ 4 | 5 | class Cylindrical { 6 | 7 | constructor( radius = 1, theta = 0, y = 0 ) { 8 | 9 | this.radius = radius; // distance from the origin to a point in the x-z plane 10 | this.theta = theta; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis 11 | this.y = y; // height above the x-z plane 12 | 13 | return this; 14 | 15 | } 16 | 17 | set( radius, theta, y ) { 18 | 19 | this.radius = radius; 20 | this.theta = theta; 21 | this.y = y; 22 | 23 | return this; 24 | 25 | } 26 | 27 | copy( other ) { 28 | 29 | this.radius = other.radius; 30 | this.theta = other.theta; 31 | this.y = other.y; 32 | 33 | return this; 34 | 35 | } 36 | 37 | setFromVector3( v ) { 38 | 39 | return this.setFromCartesianCoords( v.x, v.y, v.z ); 40 | 41 | } 42 | 43 | setFromCartesianCoords( x, y, z ) { 44 | 45 | this.radius = Math.sqrt( x * x + z * z ); 46 | this.theta = Math.atan2( x, z ); 47 | this.y = y; 48 | 49 | return this; 50 | 51 | } 52 | 53 | clone() { 54 | 55 | return new this.constructor().copy( this ); 56 | 57 | } 58 | 59 | } 60 | 61 | export { Cylindrical }; 62 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/PointLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { PointLightShadow } from './PointLightShadow.js'; 3 | 4 | class PointLight extends Light { 5 | 6 | constructor( color, intensity, distance = 0, decay = 2 ) { 7 | 8 | super( color, intensity ); 9 | 10 | this.isPointLight = true; 11 | 12 | this.type = 'PointLight'; 13 | 14 | this.distance = distance; 15 | this.decay = decay; 16 | 17 | this.shadow = new PointLightShadow(); 18 | 19 | } 20 | 21 | get power() { 22 | 23 | // compute the light's luminous power (in lumens) from its intensity (in candela) 24 | // for an isotropic light source, luminous power (lm) = 4 π luminous intensity (cd) 25 | return this.intensity * 4 * Math.PI; 26 | 27 | } 28 | 29 | set power( power ) { 30 | 31 | // set the light's intensity (in candela) from the desired luminous power (in lumens) 32 | this.intensity = power / ( 4 * Math.PI ); 33 | 34 | } 35 | 36 | dispose() { 37 | 38 | this.shadow.dispose(); 39 | 40 | } 41 | 42 | copy( source, recursive ) { 43 | 44 | super.copy( source, recursive ); 45 | 46 | this.distance = source.distance; 47 | this.decay = source.decay; 48 | 49 | this.shadow = source.shadow.clone(); 50 | 51 | return this; 52 | 53 | } 54 | 55 | } 56 | 57 | export { PointLight }; 58 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_TRANSMISSION 3 | 4 | material.transmission = transmission; 5 | material.transmissionAlpha = 1.0; 6 | material.thickness = thickness; 7 | material.attenuationDistance = attenuationDistance; 8 | material.attenuationColor = attenuationColor; 9 | 10 | #ifdef USE_TRANSMISSIONMAP 11 | 12 | material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; 13 | 14 | #endif 15 | 16 | #ifdef USE_THICKNESSMAP 17 | 18 | material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; 19 | 20 | #endif 21 | 22 | vec3 pos = vWorldPosition; 23 | vec3 v = normalize( cameraPosition - pos ); 24 | vec3 n = inverseTransformDirection( normal, viewMatrix ); 25 | 26 | vec4 transmitted = getIBLVolumeRefraction( 27 | n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, 28 | pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness, 29 | material.attenuationColor, material.attenuationDistance ); 30 | 31 | material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); 32 | 33 | totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); 34 | 35 | #endif 36 | `; 37 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/AnimationLoader.js: -------------------------------------------------------------------------------- 1 | import { AnimationClip } from '../animation/AnimationClip.js'; 2 | import { FileLoader } from './FileLoader.js'; 3 | import { Loader } from './Loader.js'; 4 | 5 | class AnimationLoader extends Loader { 6 | 7 | constructor( manager ) { 8 | 9 | super( manager ); 10 | 11 | } 12 | 13 | load( url, onLoad, onProgress, onError ) { 14 | 15 | const scope = this; 16 | 17 | const loader = new FileLoader( this.manager ); 18 | loader.setPath( this.path ); 19 | loader.setRequestHeader( this.requestHeader ); 20 | loader.setWithCredentials( this.withCredentials ); 21 | loader.load( url, function ( text ) { 22 | 23 | try { 24 | 25 | onLoad( scope.parse( JSON.parse( text ) ) ); 26 | 27 | } catch ( e ) { 28 | 29 | if ( onError ) { 30 | 31 | onError( e ); 32 | 33 | } else { 34 | 35 | console.error( e ); 36 | 37 | } 38 | 39 | scope.manager.itemError( url ); 40 | 41 | } 42 | 43 | }, onProgress, onError ); 44 | 45 | } 46 | 47 | parse( json ) { 48 | 49 | const animations = []; 50 | 51 | for ( let i = 0; i < json.length; i ++ ) { 52 | 53 | const clip = AnimationClip.parse( json[ i ] ); 54 | 55 | animations.push( clip ); 56 | 57 | } 58 | 59 | return animations; 60 | 61 | } 62 | 63 | } 64 | 65 | 66 | export { AnimationLoader }; 67 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec3 vViewPosition; 3 | 4 | struct BlinnPhongMaterial { 5 | 6 | vec3 diffuseColor; 7 | vec3 specularColor; 8 | float specularShininess; 9 | float specularStrength; 10 | 11 | }; 12 | 13 | void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 14 | 15 | float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); 16 | vec3 irradiance = dotNL * directLight.color; 17 | 18 | reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 19 | 20 | reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength; 21 | 22 | } 23 | 24 | void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 25 | 26 | reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); 27 | 28 | } 29 | 30 | #define RE_Direct RE_Direct_BlinnPhong 31 | #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong 32 | `; 33 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLBufferRenderer.js: -------------------------------------------------------------------------------- 1 | function WebGLBufferRenderer( gl, extensions, info, capabilities ) { 2 | 3 | const isWebGL2 = capabilities.isWebGL2; 4 | 5 | let mode; 6 | 7 | function setMode( value ) { 8 | 9 | mode = value; 10 | 11 | } 12 | 13 | function render( start, count ) { 14 | 15 | gl.drawArrays( mode, start, count ); 16 | 17 | info.update( count, mode, 1 ); 18 | 19 | } 20 | 21 | function renderInstances( start, count, primcount ) { 22 | 23 | if ( primcount === 0 ) return; 24 | 25 | let extension, methodName; 26 | 27 | if ( isWebGL2 ) { 28 | 29 | extension = gl; 30 | methodName = 'drawArraysInstanced'; 31 | 32 | } else { 33 | 34 | extension = extensions.get( 'ANGLE_instanced_arrays' ); 35 | methodName = 'drawArraysInstancedANGLE'; 36 | 37 | if ( extension === null ) { 38 | 39 | console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); 40 | return; 41 | 42 | } 43 | 44 | } 45 | 46 | extension[ methodName ]( mode, start, count, primcount ); 47 | 48 | info.update( count, mode, primcount ); 49 | 50 | } 51 | 52 | // 53 | 54 | this.setMode = setMode; 55 | this.render = render; 56 | this.renderInstances = renderInstances; 57 | 58 | } 59 | 60 | 61 | export { WebGLBufferRenderer }; 62 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_BUMPMAP 3 | 4 | uniform sampler2D bumpMap; 5 | uniform float bumpScale; 6 | 7 | // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen 8 | // https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf 9 | 10 | // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2) 11 | 12 | vec2 dHdxy_fwd() { 13 | 14 | vec2 dSTdx = dFdx( vBumpMapUv ); 15 | vec2 dSTdy = dFdy( vBumpMapUv ); 16 | 17 | float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x; 18 | float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll; 19 | float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll; 20 | 21 | return vec2( dBx, dBy ); 22 | 23 | } 24 | 25 | vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) { 26 | 27 | vec3 vSigmaX = dFdx( surf_pos.xyz ); 28 | vec3 vSigmaY = dFdy( surf_pos.xyz ); 29 | vec3 vN = surf_norm; // normalized 30 | 31 | vec3 R1 = cross( vSigmaY, vN ); 32 | vec3 R2 = cross( vN, vSigmaX ); 33 | 34 | float fDet = dot( vSigmaX, R1 ) * faceDirection; 35 | 36 | vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); 37 | return normalize( abs( fDet ) * surf_norm - vGrad ); 38 | 39 | } 40 | 41 | #endif 42 | `; 43 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLInfo.js: -------------------------------------------------------------------------------- 1 | function WebGLInfo( gl ) { 2 | 3 | const memory = { 4 | geometries: 0, 5 | textures: 0 6 | }; 7 | 8 | const render = { 9 | frame: 0, 10 | calls: 0, 11 | triangles: 0, 12 | points: 0, 13 | lines: 0 14 | }; 15 | 16 | function update( count, mode, instanceCount ) { 17 | 18 | render.calls ++; 19 | 20 | switch ( mode ) { 21 | 22 | case gl.TRIANGLES: 23 | render.triangles += instanceCount * ( count / 3 ); 24 | break; 25 | 26 | case gl.LINES: 27 | render.lines += instanceCount * ( count / 2 ); 28 | break; 29 | 30 | case gl.LINE_STRIP: 31 | render.lines += instanceCount * ( count - 1 ); 32 | break; 33 | 34 | case gl.LINE_LOOP: 35 | render.lines += instanceCount * count; 36 | break; 37 | 38 | case gl.POINTS: 39 | render.points += instanceCount * count; 40 | break; 41 | 42 | default: 43 | console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode ); 44 | break; 45 | 46 | } 47 | 48 | } 49 | 50 | function reset() { 51 | 52 | render.calls = 0; 53 | render.triangles = 0; 54 | render.points = 0; 55 | render.lines = 0; 56 | 57 | } 58 | 59 | return { 60 | memory: memory, 61 | render: render, 62 | programs: null, 63 | autoReset: true, 64 | reset: reset, 65 | update: update 66 | }; 67 | 68 | } 69 | 70 | 71 | export { WebGLInfo }; 72 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/VideoTexture.js: -------------------------------------------------------------------------------- 1 | import { LinearFilter } from '../constants.js'; 2 | import { Texture } from './Texture.js'; 3 | 4 | class VideoTexture extends Texture { 5 | 6 | constructor( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { 7 | 8 | super( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); 9 | 10 | this.isVideoTexture = true; 11 | 12 | this.minFilter = minFilter !== undefined ? minFilter : LinearFilter; 13 | this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; 14 | 15 | this.generateMipmaps = false; 16 | 17 | const scope = this; 18 | 19 | function updateVideo() { 20 | 21 | scope.needsUpdate = true; 22 | video.requestVideoFrameCallback( updateVideo ); 23 | 24 | } 25 | 26 | if ( 'requestVideoFrameCallback' in video ) { 27 | 28 | video.requestVideoFrameCallback( updateVideo ); 29 | 30 | } 31 | 32 | } 33 | 34 | clone() { 35 | 36 | return new this.constructor( this.image ).copy( this ); 37 | 38 | } 39 | 40 | update() { 41 | 42 | const video = this.image; 43 | const hasVideoFrameCallback = 'requestVideoFrameCallback' in video; 44 | 45 | if ( hasVideoFrameCallback === false && video.readyState >= video.HAVE_CURRENT_DATA ) { 46 | 47 | this.needsUpdate = true; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | export { VideoTexture }; 56 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/Loader.js: -------------------------------------------------------------------------------- 1 | import { DefaultLoadingManager } from './LoadingManager.js'; 2 | 3 | class Loader { 4 | 5 | constructor( manager ) { 6 | 7 | this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; 8 | 9 | this.crossOrigin = 'anonymous'; 10 | this.withCredentials = false; 11 | this.path = ''; 12 | this.resourcePath = ''; 13 | this.requestHeader = {}; 14 | 15 | } 16 | 17 | load( /* url, onLoad, onProgress, onError */ ) {} 18 | 19 | loadAsync( url, onProgress ) { 20 | 21 | const scope = this; 22 | 23 | return new Promise( function ( resolve, reject ) { 24 | 25 | scope.load( url, resolve, onProgress, reject ); 26 | 27 | } ); 28 | 29 | } 30 | 31 | parse( /* data */ ) {} 32 | 33 | setCrossOrigin( crossOrigin ) { 34 | 35 | this.crossOrigin = crossOrigin; 36 | return this; 37 | 38 | } 39 | 40 | setWithCredentials( value ) { 41 | 42 | this.withCredentials = value; 43 | return this; 44 | 45 | } 46 | 47 | setPath( path ) { 48 | 49 | this.path = path; 50 | return this; 51 | 52 | } 53 | 54 | setResourcePath( resourcePath ) { 55 | 56 | this.resourcePath = resourcePath; 57 | return this; 58 | 59 | } 60 | 61 | setRequestHeader( requestHeader ) { 62 | 63 | this.requestHeader = requestHeader; 64 | return this; 65 | 66 | } 67 | 68 | } 69 | 70 | Loader.DEFAULT_MATERIAL_NAME = '__DEFAULT'; 71 | 72 | export { Loader }; 73 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/backgroundCube.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | varying vec3 vWorldDirection; 3 | 4 | #include 5 | 6 | void main() { 7 | 8 | vWorldDirection = transformDirection( position, modelMatrix ); 9 | 10 | #include 11 | #include 12 | 13 | gl_Position.z = gl_Position.w; // set z to camera.far 14 | 15 | } 16 | `; 17 | 18 | export const fragment = /* glsl */` 19 | 20 | #ifdef ENVMAP_TYPE_CUBE 21 | 22 | uniform samplerCube envMap; 23 | 24 | #elif defined( ENVMAP_TYPE_CUBE_UV ) 25 | 26 | uniform sampler2D envMap; 27 | 28 | #endif 29 | 30 | uniform float flipEnvMap; 31 | uniform float backgroundBlurriness; 32 | uniform float backgroundIntensity; 33 | 34 | varying vec3 vWorldDirection; 35 | 36 | #include 37 | 38 | void main() { 39 | 40 | #ifdef ENVMAP_TYPE_CUBE 41 | 42 | vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); 43 | 44 | #elif defined( ENVMAP_TYPE_CUBE_UV ) 45 | 46 | vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness ); 47 | 48 | #else 49 | 50 | vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); 51 | 52 | #endif 53 | 54 | texColor.rgb *= backgroundIntensity; 55 | 56 | gl_FragColor = texColor; 57 | 58 | #include 59 | #include 60 | 61 | } 62 | `; 63 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/shadow.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void main() { 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | } 28 | `; 29 | 30 | export const fragment = /* glsl */` 31 | uniform vec3 color; 32 | uniform float opacity; 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | void main() { 44 | 45 | #include 46 | 47 | gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); 48 | 49 | #include 50 | #include 51 | #include 52 | 53 | } 54 | `; 55 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MORPHTARGETS 3 | 4 | // morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value: 5 | // When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence) 6 | // When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting 7 | transformed *= morphTargetBaseInfluence; 8 | 9 | #ifdef MORPHTARGETS_TEXTURE 10 | 11 | for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { 12 | 13 | if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; 14 | 15 | } 16 | 17 | #else 18 | 19 | transformed += morphTarget0 * morphTargetInfluences[ 0 ]; 20 | transformed += morphTarget1 * morphTargetInfluences[ 1 ]; 21 | transformed += morphTarget2 * morphTargetInfluences[ 2 ]; 22 | transformed += morphTarget3 * morphTargetInfluences[ 3 ]; 23 | 24 | #ifndef USE_MORPHNORMALS 25 | 26 | transformed += morphTarget4 * morphTargetInfluences[ 4 ]; 27 | transformed += morphTarget5 * morphTargetInfluences[ 5 ]; 28 | transformed += morphTarget6 * morphTargetInfluences[ 6 ]; 29 | transformed += morphTarget7 * morphTargetInfluences[ 7 ]; 30 | 31 | #endif 32 | 33 | #endif 34 | 35 | #endif 36 | `; 37 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/Light.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | class Light extends Object3D { 5 | 6 | constructor( color, intensity = 1 ) { 7 | 8 | super(); 9 | 10 | this.isLight = true; 11 | 12 | this.type = 'Light'; 13 | 14 | this.color = new Color( color ); 15 | this.intensity = intensity; 16 | 17 | } 18 | 19 | dispose() { 20 | 21 | // Empty here in base class; some subclasses override. 22 | 23 | } 24 | 25 | copy( source, recursive ) { 26 | 27 | super.copy( source, recursive ); 28 | 29 | this.color.copy( source.color ); 30 | this.intensity = source.intensity; 31 | 32 | return this; 33 | 34 | } 35 | 36 | toJSON( meta ) { 37 | 38 | const data = super.toJSON( meta ); 39 | 40 | data.object.color = this.color.getHex(); 41 | data.object.intensity = this.intensity; 42 | 43 | if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex(); 44 | 45 | if ( this.distance !== undefined ) data.object.distance = this.distance; 46 | if ( this.angle !== undefined ) data.object.angle = this.angle; 47 | if ( this.decay !== undefined ) data.object.decay = this.decay; 48 | if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra; 49 | 50 | if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON(); 51 | 52 | return data; 53 | 54 | } 55 | 56 | } 57 | 58 | export { Light }; 59 | -------------------------------------------------------------------------------- /src/joiner.rs: -------------------------------------------------------------------------------- 1 | use crate::{CowStr, MagicString}; 2 | 3 | pub struct JoinerOptions { 4 | pub separator: Option, 5 | } 6 | 7 | #[derive(Default)] 8 | pub struct Joiner<'s> { 9 | sources: Vec>, 10 | separator: Option, 11 | } 12 | 13 | impl<'s> Joiner<'s> { 14 | // --- public 15 | pub fn new() -> Self { 16 | Self::default() 17 | } 18 | 19 | pub fn with_options(options: JoinerOptions) -> Self { 20 | Self { separator: options.separator, ..Default::default() } 21 | } 22 | 23 | pub fn append(&mut self, source: MagicString<'s>) -> &mut Self { 24 | self.sources.push(source); 25 | self 26 | } 27 | 28 | pub fn append_raw(&mut self, raw: impl Into>) -> &mut Self { 29 | self.sources.push(MagicString::new(raw)); 30 | self 31 | } 32 | 33 | pub fn len(&self) -> usize { 34 | self.fragments().map(|s| s.len()).sum() 35 | } 36 | 37 | pub fn join(&self) -> String { 38 | let mut ret = String::with_capacity(self.len()); 39 | self.fragments().for_each(|frag| { 40 | ret.push_str(frag); 41 | }); 42 | ret 43 | } 44 | 45 | // --- private 46 | 47 | fn fragments(&'s self) -> impl Iterator { 48 | let mut iter = 49 | self.sources.iter().flat_map(|c| self.separator.as_deref().into_iter().chain(c.fragments())); 50 | // Drop the first separator 51 | if self.separator.is_some() { 52 | iter.next(); 53 | } 54 | iter 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | // http://www.russellcottrell.com/photo/matrixCalculator.htm 4 | 5 | // Linear sRGB => XYZ => Linear Display P3 6 | const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( 7 | vec3( 0.8224621, 0.177538, 0.0 ), 8 | vec3( 0.0331941, 0.9668058, 0.0 ), 9 | vec3( 0.0170827, 0.0723974, 0.9105199 ) 10 | ); 11 | 12 | // Linear Display P3 => XYZ => Linear sRGB 13 | const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( 14 | vec3( 1.2249401, - 0.2249404, 0.0 ), 15 | vec3( - 0.0420569, 1.0420571, 0.0 ), 16 | vec3( - 0.0196376, - 0.0786361, 1.0982735 ) 17 | ); 18 | 19 | vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { 20 | return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); 21 | } 22 | 23 | vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { 24 | return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); 25 | } 26 | 27 | vec4 LinearTransferOETF( in vec4 value ) { 28 | return value; 29 | } 30 | 31 | vec4 sRGBTransferOETF( in vec4 value ) { 32 | return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); 33 | } 34 | 35 | // @deprecated, r156 36 | vec4 LinearToLinear( in vec4 value ) { 37 | return value; 38 | } 39 | 40 | // @deprecated, r156 41 | vec4 LinearTosRGB( in vec4 value ) { 42 | return sRGBTransferOETF( value ); 43 | } 44 | `; 45 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/vsm.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | void main() { 3 | 4 | gl_Position = vec4( position, 1.0 ); 5 | 6 | } 7 | `; 8 | 9 | export const fragment = /* glsl */` 10 | uniform sampler2D shadow_pass; 11 | uniform vec2 resolution; 12 | uniform float radius; 13 | 14 | #include 15 | 16 | void main() { 17 | 18 | const float samples = float( VSM_SAMPLES ); 19 | 20 | float mean = 0.0; 21 | float squared_mean = 0.0; 22 | 23 | float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); 24 | float uvStart = samples <= 1.0 ? 0.0 : - 1.0; 25 | for ( float i = 0.0; i < samples; i ++ ) { 26 | 27 | float uvOffset = uvStart + i * uvStride; 28 | 29 | #ifdef HORIZONTAL_PASS 30 | 31 | vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); 32 | mean += distribution.x; 33 | squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; 34 | 35 | #else 36 | 37 | float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); 38 | mean += depth; 39 | squared_mean += depth * depth; 40 | 41 | #endif 42 | 43 | } 44 | 45 | mean = mean / samples; 46 | squared_mean = squared_mean / samples; 47 | 48 | float std_dev = sqrt( squared_mean - mean * mean ); 49 | 50 | gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); 51 | 52 | } 53 | `; 54 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/AudioLoader.js: -------------------------------------------------------------------------------- 1 | import { AudioContext } from '../audio/AudioContext.js'; 2 | import { FileLoader } from './FileLoader.js'; 3 | import { Loader } from './Loader.js'; 4 | 5 | class AudioLoader extends Loader { 6 | 7 | constructor( manager ) { 8 | 9 | super( manager ); 10 | 11 | } 12 | 13 | load( url, onLoad, onProgress, onError ) { 14 | 15 | const scope = this; 16 | 17 | const loader = new FileLoader( this.manager ); 18 | loader.setResponseType( 'arraybuffer' ); 19 | loader.setPath( this.path ); 20 | loader.setRequestHeader( this.requestHeader ); 21 | loader.setWithCredentials( this.withCredentials ); 22 | loader.load( url, function ( buffer ) { 23 | 24 | try { 25 | 26 | // Create a copy of the buffer. The `decodeAudioData` method 27 | // detaches the buffer when complete, preventing reuse. 28 | const bufferCopy = buffer.slice( 0 ); 29 | 30 | const context = AudioContext.getContext(); 31 | context.decodeAudioData( bufferCopy, function ( audioBuffer ) { 32 | 33 | onLoad( audioBuffer ); 34 | 35 | }, handleError ); 36 | 37 | } catch ( e ) { 38 | 39 | handleError( e ); 40 | 41 | } 42 | 43 | }, onProgress, onError ); 44 | 45 | function handleError( e ) { 46 | 47 | if ( onError ) { 48 | 49 | onError( e ); 50 | 51 | } else { 52 | 53 | console.error( e ); 54 | 55 | } 56 | 57 | scope.manager.itemError( url ); 58 | 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | 66 | export { AudioLoader }; 67 | -------------------------------------------------------------------------------- /src/magic_string/source_map.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Arc; 2 | 3 | use crate::{ 4 | source_map::{locator::Locator, sourcemap_builder::SourcemapBuilder}, 5 | MagicString, 6 | }; 7 | 8 | #[derive(Debug)] 9 | pub struct SourceMapOptions { 10 | pub include_content: bool, 11 | pub source: Arc, 12 | pub hires: bool, 13 | } 14 | 15 | impl Default for SourceMapOptions { 16 | fn default() -> Self { 17 | Self { include_content: false, source: "".into(), hires: false } 18 | } 19 | } 20 | 21 | impl<'s> MagicString<'s> { 22 | pub fn source_map(&self, opts: SourceMapOptions) -> oxc_sourcemap::SourceMap { 23 | let mut source_builder = SourcemapBuilder::new(opts.hires); 24 | 25 | source_builder.set_source_and_content(&opts.source, &self.source); 26 | 27 | let locator = Locator::new(&self.source); 28 | 29 | self.intro.iter().for_each(|frag| { 30 | source_builder.advance(frag); 31 | }); 32 | 33 | self.iter_chunks().for_each(|chunk| { 34 | chunk.intro.iter().for_each(|frag| { 35 | source_builder.advance(frag); 36 | }); 37 | 38 | let name = if chunk.keep_in_mappings && chunk.is_edited() { 39 | Some(chunk.span.text(&self.source)) 40 | } else { 41 | None 42 | }; 43 | 44 | source_builder.add_chunk(chunk, &locator, &self.source, name); 45 | 46 | chunk.outro.iter().for_each(|frag| { 47 | source_builder.advance(frag); 48 | }); 49 | }); 50 | 51 | source_builder.into_source_map() 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /fixtures/threejs_src/objects/LineSegments.js: -------------------------------------------------------------------------------- 1 | import { Line } from './Line.js'; 2 | import { Vector3 } from '../math/Vector3.js'; 3 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 4 | 5 | const _start = /*@__PURE__*/ new Vector3(); 6 | const _end = /*@__PURE__*/ new Vector3(); 7 | 8 | class LineSegments extends Line { 9 | 10 | constructor( geometry, material ) { 11 | 12 | super( geometry, material ); 13 | 14 | this.isLineSegments = true; 15 | 16 | this.type = 'LineSegments'; 17 | 18 | } 19 | 20 | computeLineDistances() { 21 | 22 | const geometry = this.geometry; 23 | 24 | // we assume non-indexed geometry 25 | 26 | if ( geometry.index === null ) { 27 | 28 | const positionAttribute = geometry.attributes.position; 29 | const lineDistances = []; 30 | 31 | for ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) { 32 | 33 | _start.fromBufferAttribute( positionAttribute, i ); 34 | _end.fromBufferAttribute( positionAttribute, i + 1 ); 35 | 36 | lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ]; 37 | lineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end ); 38 | 39 | } 40 | 41 | geometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) ); 42 | 43 | } else { 44 | 45 | console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' ); 46 | 47 | } 48 | 49 | return this; 50 | 51 | } 52 | 53 | } 54 | 55 | export { LineSegments }; 56 | -------------------------------------------------------------------------------- /src/magic_string/append.rs: -------------------------------------------------------------------------------- 1 | use crate::CowStr; 2 | 3 | use super::MagicString; 4 | 5 | impl<'text> MagicString<'text> { 6 | pub fn append(&mut self, source: impl Into>) -> &mut Self { 7 | self.append_outro(source.into()); 8 | self 9 | } 10 | 11 | /// # Example 12 | ///```rust 13 | /// use string_wizard::MagicString; 14 | /// let mut s = MagicString::new("01234"); 15 | /// s.append_left(2, "a"); 16 | /// s.append_left(2, "b"); 17 | /// assert_eq!(s.to_string(), "01ab234") 18 | ///``` 19 | pub fn append_left(&mut self, text_index: usize, content: impl Into>) -> &mut Self { 20 | match self.by_end_mut(text_index) { 21 | Some(chunk) => { 22 | chunk.append_outro(content.into()); 23 | } 24 | None => self.append_intro(content.into()), 25 | } 26 | self 27 | } 28 | 29 | /// # Example 30 | /// ```rust 31 | /// use string_wizard::MagicString; 32 | /// let mut s = MagicString::new("01234"); 33 | /// s.append_right(2, "A"); 34 | /// s.append_right(2, "B"); 35 | /// s.append_left(2, "a"); 36 | /// s.append_left(2, "b"); 37 | /// assert_eq!(s.to_string(), "01abAB234") 38 | ///``` 39 | pub fn append_right( 40 | &mut self, 41 | text_index: usize, 42 | content: impl Into>, 43 | ) -> &mut Self { 44 | match self.by_start_mut(text_index) { 45 | Some(chunk) => { 46 | chunk.append_intro(content.into()); 47 | } 48 | None => self.append_outro(content.into()), 49 | } 50 | self 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /fixtures/threejs_src/helpers/Box3Helper.js: -------------------------------------------------------------------------------- 1 | import { LineSegments } from '../objects/LineSegments.js'; 2 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 3 | import { BufferAttribute, Float32BufferAttribute } from '../core/BufferAttribute.js'; 4 | import { BufferGeometry } from '../core/BufferGeometry.js'; 5 | 6 | class Box3Helper extends LineSegments { 7 | 8 | constructor( box, color = 0xffff00 ) { 9 | 10 | const indices = new Uint16Array( [ 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 ] ); 11 | 12 | const positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ]; 13 | 14 | const geometry = new BufferGeometry(); 15 | 16 | geometry.setIndex( new BufferAttribute( indices, 1 ) ); 17 | 18 | geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); 19 | 20 | super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); 21 | 22 | this.box = box; 23 | 24 | this.type = 'Box3Helper'; 25 | 26 | this.geometry.computeBoundingSphere(); 27 | 28 | } 29 | 30 | updateMatrixWorld( force ) { 31 | 32 | const box = this.box; 33 | 34 | if ( box.isEmpty() ) return; 35 | 36 | box.getCenter( this.position ); 37 | 38 | box.getSize( this.scale ); 39 | 40 | this.scale.multiplyScalar( 0.5 ); 41 | 42 | super.updateMatrixWorld( force ); 43 | 44 | } 45 | 46 | dispose() { 47 | 48 | this.geometry.dispose(); 49 | this.material.dispose(); 50 | 51 | } 52 | 53 | } 54 | 55 | export { Box3Helper }; 56 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/QuadraticBezierCurve.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { QuadraticBezier } from '../core/Interpolations.js'; 3 | import { Vector2 } from '../../math/Vector2.js'; 4 | 5 | class QuadraticBezierCurve extends Curve { 6 | 7 | constructor( v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2() ) { 8 | 9 | super(); 10 | 11 | this.isQuadraticBezierCurve = true; 12 | 13 | this.type = 'QuadraticBezierCurve'; 14 | 15 | this.v0 = v0; 16 | this.v1 = v1; 17 | this.v2 = v2; 18 | 19 | } 20 | 21 | getPoint( t, optionalTarget = new Vector2() ) { 22 | 23 | const point = optionalTarget; 24 | 25 | const v0 = this.v0, v1 = this.v1, v2 = this.v2; 26 | 27 | point.set( 28 | QuadraticBezier( t, v0.x, v1.x, v2.x ), 29 | QuadraticBezier( t, v0.y, v1.y, v2.y ) 30 | ); 31 | 32 | return point; 33 | 34 | } 35 | 36 | copy( source ) { 37 | 38 | super.copy( source ); 39 | 40 | this.v0.copy( source.v0 ); 41 | this.v1.copy( source.v1 ); 42 | this.v2.copy( source.v2 ); 43 | 44 | return this; 45 | 46 | } 47 | 48 | toJSON() { 49 | 50 | const data = super.toJSON(); 51 | 52 | data.v0 = this.v0.toArray(); 53 | data.v1 = this.v1.toArray(); 54 | data.v2 = this.v2.toArray(); 55 | 56 | return data; 57 | 58 | } 59 | 60 | fromJSON( json ) { 61 | 62 | super.fromJSON( json ); 63 | 64 | this.v0.fromArray( json.v0 ); 65 | this.v1.fromArray( json.v1 ); 66 | this.v2.fromArray( json.v2 ); 67 | 68 | return this; 69 | 70 | } 71 | 72 | } 73 | 74 | export { QuadraticBezierCurve }; 75 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/MeshNormalMaterial.js: -------------------------------------------------------------------------------- 1 | import { TangentSpaceNormalMap } from '../constants.js'; 2 | import { Material } from './Material.js'; 3 | import { Vector2 } from '../math/Vector2.js'; 4 | 5 | class MeshNormalMaterial extends Material { 6 | 7 | constructor( parameters ) { 8 | 9 | super(); 10 | 11 | this.isMeshNormalMaterial = true; 12 | 13 | this.type = 'MeshNormalMaterial'; 14 | 15 | this.bumpMap = null; 16 | this.bumpScale = 1; 17 | 18 | this.normalMap = null; 19 | this.normalMapType = TangentSpaceNormalMap; 20 | this.normalScale = new Vector2( 1, 1 ); 21 | 22 | this.displacementMap = null; 23 | this.displacementScale = 1; 24 | this.displacementBias = 0; 25 | 26 | this.wireframe = false; 27 | this.wireframeLinewidth = 1; 28 | 29 | this.flatShading = false; 30 | 31 | this.setValues( parameters ); 32 | 33 | } 34 | 35 | copy( source ) { 36 | 37 | super.copy( source ); 38 | 39 | this.bumpMap = source.bumpMap; 40 | this.bumpScale = source.bumpScale; 41 | 42 | this.normalMap = source.normalMap; 43 | this.normalMapType = source.normalMapType; 44 | this.normalScale.copy( source.normalScale ); 45 | 46 | this.displacementMap = source.displacementMap; 47 | this.displacementScale = source.displacementScale; 48 | this.displacementBias = source.displacementBias; 49 | 50 | this.wireframe = source.wireframe; 51 | this.wireframeLinewidth = source.wireframeLinewidth; 52 | 53 | this.flatShading = source.flatShading; 54 | 55 | return this; 56 | 57 | } 58 | 59 | } 60 | 61 | export { MeshNormalMaterial }; 62 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | #ifdef ENV_WORLDPOS 5 | 6 | vec3 cameraToFrag; 7 | 8 | if ( isOrthographic ) { 9 | 10 | cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); 11 | 12 | } else { 13 | 14 | cameraToFrag = normalize( vWorldPosition - cameraPosition ); 15 | 16 | } 17 | 18 | // Transforming Normal Vectors with the Inverse Transformation 19 | vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 20 | 21 | #ifdef ENVMAP_MODE_REFLECTION 22 | 23 | vec3 reflectVec = reflect( cameraToFrag, worldNormal ); 24 | 25 | #else 26 | 27 | vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); 28 | 29 | #endif 30 | 31 | #else 32 | 33 | vec3 reflectVec = vReflect; 34 | 35 | #endif 36 | 37 | #ifdef ENVMAP_TYPE_CUBE 38 | 39 | vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); 40 | 41 | #else 42 | 43 | vec4 envColor = vec4( 0.0 ); 44 | 45 | #endif 46 | 47 | #ifdef ENVMAP_BLENDING_MULTIPLY 48 | 49 | outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); 50 | 51 | #elif defined( ENVMAP_BLENDING_MIX ) 52 | 53 | outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); 54 | 55 | #elif defined( ENVMAP_BLENDING_ADD ) 56 | 57 | outgoingLight += envColor.xyz * specularStrength * reflectivity; 58 | 59 | #endif 60 | 61 | #endif 62 | `; 63 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/Materials.js: -------------------------------------------------------------------------------- 1 | import { ShadowMaterial } from './ShadowMaterial.js'; 2 | import { SpriteMaterial } from './SpriteMaterial.js'; 3 | import { RawShaderMaterial } from './RawShaderMaterial.js'; 4 | import { ShaderMaterial } from './ShaderMaterial.js'; 5 | import { PointsMaterial } from './PointsMaterial.js'; 6 | import { MeshPhysicalMaterial } from './MeshPhysicalMaterial.js'; 7 | import { MeshStandardMaterial } from './MeshStandardMaterial.js'; 8 | import { MeshPhongMaterial } from './MeshPhongMaterial.js'; 9 | import { MeshToonMaterial } from './MeshToonMaterial.js'; 10 | import { MeshNormalMaterial } from './MeshNormalMaterial.js'; 11 | import { MeshLambertMaterial } from './MeshLambertMaterial.js'; 12 | import { MeshDepthMaterial } from './MeshDepthMaterial.js'; 13 | import { MeshDistanceMaterial } from './MeshDistanceMaterial.js'; 14 | import { MeshBasicMaterial } from './MeshBasicMaterial.js'; 15 | import { MeshMatcapMaterial } from './MeshMatcapMaterial.js'; 16 | import { LineDashedMaterial } from './LineDashedMaterial.js'; 17 | import { LineBasicMaterial } from './LineBasicMaterial.js'; 18 | import { Material } from './Material.js'; 19 | 20 | export { 21 | ShadowMaterial, 22 | SpriteMaterial, 23 | RawShaderMaterial, 24 | ShaderMaterial, 25 | PointsMaterial, 26 | MeshPhysicalMaterial, 27 | MeshStandardMaterial, 28 | MeshPhongMaterial, 29 | MeshToonMaterial, 30 | MeshNormalMaterial, 31 | MeshLambertMaterial, 32 | MeshDepthMaterial, 33 | MeshDistanceMaterial, 34 | MeshBasicMaterial, 35 | MeshMatcapMaterial, 36 | LineDashedMaterial, 37 | LineBasicMaterial, 38 | Material 39 | }; 40 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/core/Interpolations.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Bezier Curves formulas obtained from 3 | * https://en.wikipedia.org/wiki/B%C3%A9zier_curve 4 | */ 5 | 6 | function CatmullRom( t, p0, p1, p2, p3 ) { 7 | 8 | const v0 = ( p2 - p0 ) * 0.5; 9 | const v1 = ( p3 - p1 ) * 0.5; 10 | const t2 = t * t; 11 | const t3 = t * t2; 12 | return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1; 13 | 14 | } 15 | 16 | // 17 | 18 | function QuadraticBezierP0( t, p ) { 19 | 20 | const k = 1 - t; 21 | return k * k * p; 22 | 23 | } 24 | 25 | function QuadraticBezierP1( t, p ) { 26 | 27 | return 2 * ( 1 - t ) * t * p; 28 | 29 | } 30 | 31 | function QuadraticBezierP2( t, p ) { 32 | 33 | return t * t * p; 34 | 35 | } 36 | 37 | function QuadraticBezier( t, p0, p1, p2 ) { 38 | 39 | return QuadraticBezierP0( t, p0 ) + QuadraticBezierP1( t, p1 ) + 40 | QuadraticBezierP2( t, p2 ); 41 | 42 | } 43 | 44 | // 45 | 46 | function CubicBezierP0( t, p ) { 47 | 48 | const k = 1 - t; 49 | return k * k * k * p; 50 | 51 | } 52 | 53 | function CubicBezierP1( t, p ) { 54 | 55 | const k = 1 - t; 56 | return 3 * k * k * t * p; 57 | 58 | } 59 | 60 | function CubicBezierP2( t, p ) { 61 | 62 | return 3 * ( 1 - t ) * t * t * p; 63 | 64 | } 65 | 66 | function CubicBezierP3( t, p ) { 67 | 68 | return t * t * t * p; 69 | 70 | } 71 | 72 | function CubicBezier( t, p0, p1, p2, p3 ) { 73 | 74 | return CubicBezierP0( t, p0 ) + CubicBezierP1( t, p1 ) + CubicBezierP2( t, p2 ) + 75 | CubicBezierP3( t, p3 ); 76 | 77 | } 78 | 79 | export { CatmullRom, QuadraticBezier, CubicBezier }; 80 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/QuadraticBezierCurve3.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { QuadraticBezier } from '../core/Interpolations.js'; 3 | import { Vector3 } from '../../math/Vector3.js'; 4 | 5 | class QuadraticBezierCurve3 extends Curve { 6 | 7 | constructor( v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3() ) { 8 | 9 | super(); 10 | 11 | this.isQuadraticBezierCurve3 = true; 12 | 13 | this.type = 'QuadraticBezierCurve3'; 14 | 15 | this.v0 = v0; 16 | this.v1 = v1; 17 | this.v2 = v2; 18 | 19 | } 20 | 21 | getPoint( t, optionalTarget = new Vector3() ) { 22 | 23 | const point = optionalTarget; 24 | 25 | const v0 = this.v0, v1 = this.v1, v2 = this.v2; 26 | 27 | point.set( 28 | QuadraticBezier( t, v0.x, v1.x, v2.x ), 29 | QuadraticBezier( t, v0.y, v1.y, v2.y ), 30 | QuadraticBezier( t, v0.z, v1.z, v2.z ) 31 | ); 32 | 33 | return point; 34 | 35 | } 36 | 37 | copy( source ) { 38 | 39 | super.copy( source ); 40 | 41 | this.v0.copy( source.v0 ); 42 | this.v1.copy( source.v1 ); 43 | this.v2.copy( source.v2 ); 44 | 45 | return this; 46 | 47 | } 48 | 49 | toJSON() { 50 | 51 | const data = super.toJSON(); 52 | 53 | data.v0 = this.v0.toArray(); 54 | data.v1 = this.v1.toArray(); 55 | data.v2 = this.v2.toArray(); 56 | 57 | return data; 58 | 59 | } 60 | 61 | fromJSON( json ) { 62 | 63 | super.fromJSON( json ); 64 | 65 | this.v0.fromArray( json.v0 ); 66 | this.v1.fromArray( json.v1 ); 67 | this.v2.fromArray( json.v2 ); 68 | 69 | return this; 70 | 71 | } 72 | 73 | } 74 | 75 | export { QuadraticBezierCurve3 }; 76 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/UniformsGroup.js: -------------------------------------------------------------------------------- 1 | import { EventDispatcher } from './EventDispatcher.js'; 2 | import { StaticDrawUsage } from '../constants.js'; 3 | 4 | let _id = 0; 5 | 6 | class UniformsGroup extends EventDispatcher { 7 | 8 | constructor() { 9 | 10 | super(); 11 | 12 | this.isUniformsGroup = true; 13 | 14 | Object.defineProperty( this, 'id', { value: _id ++ } ); 15 | 16 | this.name = ''; 17 | 18 | this.usage = StaticDrawUsage; 19 | this.uniforms = []; 20 | 21 | } 22 | 23 | add( uniform ) { 24 | 25 | this.uniforms.push( uniform ); 26 | 27 | return this; 28 | 29 | } 30 | 31 | remove( uniform ) { 32 | 33 | const index = this.uniforms.indexOf( uniform ); 34 | 35 | if ( index !== - 1 ) this.uniforms.splice( index, 1 ); 36 | 37 | return this; 38 | 39 | } 40 | 41 | setName( name ) { 42 | 43 | this.name = name; 44 | 45 | return this; 46 | 47 | } 48 | 49 | setUsage( value ) { 50 | 51 | this.usage = value; 52 | 53 | return this; 54 | 55 | } 56 | 57 | dispose() { 58 | 59 | this.dispatchEvent( { type: 'dispose' } ); 60 | 61 | return this; 62 | 63 | } 64 | 65 | copy( source ) { 66 | 67 | this.name = source.name; 68 | this.usage = source.usage; 69 | 70 | const uniformsSource = source.uniforms; 71 | 72 | this.uniforms.length = 0; 73 | 74 | for ( let i = 0, l = uniformsSource.length; i < l; i ++ ) { 75 | 76 | this.uniforms.push( uniformsSource[ i ].clone() ); 77 | 78 | } 79 | 80 | return this; 81 | 82 | } 83 | 84 | clone() { 85 | 86 | return new this.constructor().copy( this ); 87 | 88 | } 89 | 90 | } 91 | 92 | export { UniformsGroup }; 93 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLIndexedBufferRenderer.js: -------------------------------------------------------------------------------- 1 | function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { 2 | 3 | const isWebGL2 = capabilities.isWebGL2; 4 | 5 | let mode; 6 | 7 | function setMode( value ) { 8 | 9 | mode = value; 10 | 11 | } 12 | 13 | let type, bytesPerElement; 14 | 15 | function setIndex( value ) { 16 | 17 | type = value.type; 18 | bytesPerElement = value.bytesPerElement; 19 | 20 | } 21 | 22 | function render( start, count ) { 23 | 24 | gl.drawElements( mode, count, type, start * bytesPerElement ); 25 | 26 | info.update( count, mode, 1 ); 27 | 28 | } 29 | 30 | function renderInstances( start, count, primcount ) { 31 | 32 | if ( primcount === 0 ) return; 33 | 34 | let extension, methodName; 35 | 36 | if ( isWebGL2 ) { 37 | 38 | extension = gl; 39 | methodName = 'drawElementsInstanced'; 40 | 41 | } else { 42 | 43 | extension = extensions.get( 'ANGLE_instanced_arrays' ); 44 | methodName = 'drawElementsInstancedANGLE'; 45 | 46 | if ( extension === null ) { 47 | 48 | console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); 49 | return; 50 | 51 | } 52 | 53 | } 54 | 55 | extension[ methodName ]( mode, count, type, start * bytesPerElement, primcount ); 56 | 57 | info.update( count, mode, primcount ); 58 | 59 | } 60 | 61 | // 62 | 63 | this.setMode = setMode; 64 | this.setIndex = setIndex; 65 | this.render = render; 66 | this.renderInstances = renderInstances; 67 | 68 | } 69 | 70 | 71 | export { WebGLIndexedBufferRenderer }; 72 | -------------------------------------------------------------------------------- /fixtures/threejs_src/geometries/DodecahedronGeometry.js: -------------------------------------------------------------------------------- 1 | import { PolyhedronGeometry } from './PolyhedronGeometry.js'; 2 | 3 | class DodecahedronGeometry extends PolyhedronGeometry { 4 | 5 | constructor( radius = 1, detail = 0 ) { 6 | 7 | const t = ( 1 + Math.sqrt( 5 ) ) / 2; 8 | const r = 1 / t; 9 | 10 | const vertices = [ 11 | 12 | // (±1, ±1, ±1) 13 | - 1, - 1, - 1, - 1, - 1, 1, 14 | - 1, 1, - 1, - 1, 1, 1, 15 | 1, - 1, - 1, 1, - 1, 1, 16 | 1, 1, - 1, 1, 1, 1, 17 | 18 | // (0, ±1/φ, ±φ) 19 | 0, - r, - t, 0, - r, t, 20 | 0, r, - t, 0, r, t, 21 | 22 | // (±1/φ, ±φ, 0) 23 | - r, - t, 0, - r, t, 0, 24 | r, - t, 0, r, t, 0, 25 | 26 | // (±φ, 0, ±1/φ) 27 | - t, 0, - r, t, 0, - r, 28 | - t, 0, r, t, 0, r 29 | ]; 30 | 31 | const indices = [ 32 | 3, 11, 7, 3, 7, 15, 3, 15, 13, 33 | 7, 19, 17, 7, 17, 6, 7, 6, 15, 34 | 17, 4, 8, 17, 8, 10, 17, 10, 6, 35 | 8, 0, 16, 8, 16, 2, 8, 2, 10, 36 | 0, 12, 1, 0, 1, 18, 0, 18, 16, 37 | 6, 10, 2, 6, 2, 13, 6, 13, 15, 38 | 2, 16, 18, 2, 18, 3, 2, 3, 13, 39 | 18, 1, 9, 18, 9, 11, 18, 11, 3, 40 | 4, 14, 12, 4, 12, 0, 4, 0, 8, 41 | 11, 9, 5, 11, 5, 19, 11, 19, 7, 42 | 19, 5, 14, 19, 14, 4, 19, 4, 17, 43 | 1, 12, 14, 1, 14, 5, 1, 5, 9 44 | ]; 45 | 46 | super( vertices, indices, radius, detail ); 47 | 48 | this.type = 'DodecahedronGeometry'; 49 | 50 | this.parameters = { 51 | radius: radius, 52 | detail: detail 53 | }; 54 | 55 | } 56 | 57 | static fromJSON( data ) { 58 | 59 | return new DodecahedronGeometry( data.radius, data.detail ); 60 | 61 | } 62 | 63 | } 64 | 65 | 66 | export { DodecahedronGeometry }; 67 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/LoaderUtils.js: -------------------------------------------------------------------------------- 1 | class LoaderUtils { 2 | 3 | static decodeText( array ) { 4 | 5 | if ( typeof TextDecoder !== 'undefined' ) { 6 | 7 | return new TextDecoder().decode( array ); 8 | 9 | } 10 | 11 | // Avoid the String.fromCharCode.apply(null, array) shortcut, which 12 | // throws a "maximum call stack size exceeded" error for large arrays. 13 | 14 | let s = ''; 15 | 16 | for ( let i = 0, il = array.length; i < il; i ++ ) { 17 | 18 | // Implicitly assumes little-endian. 19 | s += String.fromCharCode( array[ i ] ); 20 | 21 | } 22 | 23 | try { 24 | 25 | // merges multi-byte utf-8 characters. 26 | 27 | return decodeURIComponent( escape( s ) ); 28 | 29 | } catch ( e ) { // see #16358 30 | 31 | return s; 32 | 33 | } 34 | 35 | } 36 | 37 | static extractUrlBase( url ) { 38 | 39 | const index = url.lastIndexOf( '/' ); 40 | 41 | if ( index === - 1 ) return './'; 42 | 43 | return url.slice( 0, index + 1 ); 44 | 45 | } 46 | 47 | static resolveURL( url, path ) { 48 | 49 | // Invalid URL 50 | if ( typeof url !== 'string' || url === '' ) return ''; 51 | 52 | // Host Relative URL 53 | if ( /^https?:\/\//i.test( path ) && /^\//.test( url ) ) { 54 | 55 | path = path.replace( /(^https?:\/\/[^\/]+).*/i, '$1' ); 56 | 57 | } 58 | 59 | // Absolute URL http://,https://,// 60 | if ( /^(https?:)?\/\//i.test( url ) ) return url; 61 | 62 | // Data URI 63 | if ( /^data:.*,.*$/i.test( url ) ) return url; 64 | 65 | // Blob URL 66 | if ( /^blob:.*$/i.test( url ) ) return url; 67 | 68 | // Relative URL 69 | return path + url; 70 | 71 | } 72 | 73 | } 74 | 75 | export { LoaderUtils }; 76 | -------------------------------------------------------------------------------- /benches/joiner_join.rs: -------------------------------------------------------------------------------- 1 | use criterion::{black_box, criterion_group, criterion_main, Criterion}; 2 | 3 | fn get_bunch_of_strings() -> Vec { 4 | let files = glob::glob("fixtures/threejs_src/**/*.js").unwrap(); 5 | let mut files = files.into_iter().map(|p| p.unwrap().canonicalize().unwrap()).collect::>(); 6 | files.sort(); 7 | let stirngs = files.iter().map(|p| std::fs::read_to_string(p).unwrap()).collect::>(); 8 | 9 | let mut ret = vec![]; 10 | for _ in 0..10 { 11 | ret.extend(stirngs.clone()); 12 | } 13 | ret 14 | } 15 | 16 | fn criterion_benchmark(c: &mut Criterion) { 17 | let bunch_of_strings = get_bunch_of_strings(); 18 | 19 | let mut joiner = string_wizard::Joiner::new(); 20 | bunch_of_strings.clone().into_iter().for_each(|s| { 21 | joiner.append_raw(s); 22 | }); 23 | c.bench_function("Joiner#join", |b| b.iter(|| black_box(joiner.join()))); 24 | c.bench_function("Vec#concat", |b| b.iter(|| black_box(bunch_of_strings.concat()))); 25 | c.bench_function("manual_push", |b| { 26 | b.iter(|| { 27 | let mut output = String::new(); 28 | bunch_of_strings.iter().for_each(|s| { 29 | output.push_str(s); 30 | }); 31 | black_box(output) 32 | }) 33 | }); 34 | c.bench_function("manual_push_with_cap", |b| { 35 | b.iter(|| { 36 | let cap: usize = bunch_of_strings.iter().map(|s| s.len()).sum(); 37 | let mut output = String::with_capacity(cap); 38 | bunch_of_strings.iter().for_each(|s| { 39 | output.push_str(s); 40 | }); 41 | black_box(output) 42 | }) 43 | }); 44 | } 45 | 46 | criterion_group!(benches, criterion_benchmark); 47 | criterion_main!(benches); 48 | -------------------------------------------------------------------------------- /fixtures/threejs_src/textures/DepthTexture.js: -------------------------------------------------------------------------------- 1 | import { Texture } from './Texture.js'; 2 | import { NearestFilter, UnsignedIntType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js'; 3 | 4 | class DepthTexture extends Texture { 5 | 6 | constructor( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) { 7 | 8 | format = format !== undefined ? format : DepthFormat; 9 | 10 | if ( format !== DepthFormat && format !== DepthStencilFormat ) { 11 | 12 | throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' ); 13 | 14 | } 15 | 16 | if ( type === undefined && format === DepthFormat ) type = UnsignedIntType; 17 | if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; 18 | 19 | super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); 20 | 21 | this.isDepthTexture = true; 22 | 23 | this.image = { width: width, height: height }; 24 | 25 | this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; 26 | this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; 27 | 28 | this.flipY = false; 29 | this.generateMipmaps = false; 30 | 31 | this.compareFunction = null; 32 | 33 | } 34 | 35 | 36 | copy( source ) { 37 | 38 | super.copy( source ); 39 | 40 | this.compareFunction = source.compareFunction; 41 | 42 | return this; 43 | 44 | } 45 | 46 | toJSON( meta ) { 47 | 48 | const data = super.toJSON( meta ); 49 | 50 | if ( this.compareFunction !== null ) data.compareFunction = this.compareFunction; 51 | 52 | return data; 53 | 54 | } 55 | 56 | } 57 | 58 | export { DepthTexture }; 59 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/CubicBezierCurve.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { CubicBezier } from '../core/Interpolations.js'; 3 | import { Vector2 } from '../../math/Vector2.js'; 4 | 5 | class CubicBezierCurve extends Curve { 6 | 7 | constructor( v0 = new Vector2(), v1 = new Vector2(), v2 = new Vector2(), v3 = new Vector2() ) { 8 | 9 | super(); 10 | 11 | this.isCubicBezierCurve = true; 12 | 13 | this.type = 'CubicBezierCurve'; 14 | 15 | this.v0 = v0; 16 | this.v1 = v1; 17 | this.v2 = v2; 18 | this.v3 = v3; 19 | 20 | } 21 | 22 | getPoint( t, optionalTarget = new Vector2() ) { 23 | 24 | const point = optionalTarget; 25 | 26 | const v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3; 27 | 28 | point.set( 29 | CubicBezier( t, v0.x, v1.x, v2.x, v3.x ), 30 | CubicBezier( t, v0.y, v1.y, v2.y, v3.y ) 31 | ); 32 | 33 | return point; 34 | 35 | } 36 | 37 | copy( source ) { 38 | 39 | super.copy( source ); 40 | 41 | this.v0.copy( source.v0 ); 42 | this.v1.copy( source.v1 ); 43 | this.v2.copy( source.v2 ); 44 | this.v3.copy( source.v3 ); 45 | 46 | return this; 47 | 48 | } 49 | 50 | toJSON() { 51 | 52 | const data = super.toJSON(); 53 | 54 | data.v0 = this.v0.toArray(); 55 | data.v1 = this.v1.toArray(); 56 | data.v2 = this.v2.toArray(); 57 | data.v3 = this.v3.toArray(); 58 | 59 | return data; 60 | 61 | } 62 | 63 | fromJSON( json ) { 64 | 65 | super.fromJSON( json ); 66 | 67 | this.v0.fromArray( json.v0 ); 68 | this.v1.fromArray( json.v1 ); 69 | this.v2.fromArray( json.v2 ); 70 | this.v3.fromArray( json.v3 ); 71 | 72 | return this; 73 | 74 | } 75 | 76 | } 77 | 78 | export { CubicBezierCurve }; 79 | -------------------------------------------------------------------------------- /fixtures/threejs_src/lights/SpotLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { SpotLightShadow } from './SpotLightShadow.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | class SpotLight extends Light { 6 | 7 | constructor( color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 2 ) { 8 | 9 | super( color, intensity ); 10 | 11 | this.isSpotLight = true; 12 | 13 | this.type = 'SpotLight'; 14 | 15 | this.position.copy( Object3D.DEFAULT_UP ); 16 | this.updateMatrix(); 17 | 18 | this.target = new Object3D(); 19 | 20 | this.distance = distance; 21 | this.angle = angle; 22 | this.penumbra = penumbra; 23 | this.decay = decay; 24 | 25 | this.map = null; 26 | 27 | this.shadow = new SpotLightShadow(); 28 | 29 | } 30 | 31 | get power() { 32 | 33 | // compute the light's luminous power (in lumens) from its intensity (in candela) 34 | // by convention for a spotlight, luminous power (lm) = π * luminous intensity (cd) 35 | return this.intensity * Math.PI; 36 | 37 | } 38 | 39 | set power( power ) { 40 | 41 | // set the light's intensity (in candela) from the desired luminous power (in lumens) 42 | this.intensity = power / Math.PI; 43 | 44 | } 45 | 46 | dispose() { 47 | 48 | this.shadow.dispose(); 49 | 50 | } 51 | 52 | copy( source, recursive ) { 53 | 54 | super.copy( source, recursive ); 55 | 56 | this.distance = source.distance; 57 | this.angle = source.angle; 58 | this.penumbra = source.penumbra; 59 | this.decay = source.decay; 60 | 61 | this.target = source.target.clone(); 62 | 63 | this.shadow = source.shadow.clone(); 64 | 65 | return this; 66 | 67 | } 68 | 69 | } 70 | 71 | export { SpotLight }; 72 | -------------------------------------------------------------------------------- /fixtures/threejs_src/cameras/Camera.js: -------------------------------------------------------------------------------- 1 | import { WebGLCoordinateSystem } from '../constants.js'; 2 | import { Matrix4 } from '../math/Matrix4.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | class Camera extends Object3D { 6 | 7 | constructor() { 8 | 9 | super(); 10 | 11 | this.isCamera = true; 12 | 13 | this.type = 'Camera'; 14 | 15 | this.matrixWorldInverse = new Matrix4(); 16 | 17 | this.projectionMatrix = new Matrix4(); 18 | this.projectionMatrixInverse = new Matrix4(); 19 | 20 | this.coordinateSystem = WebGLCoordinateSystem; 21 | 22 | } 23 | 24 | copy( source, recursive ) { 25 | 26 | super.copy( source, recursive ); 27 | 28 | this.matrixWorldInverse.copy( source.matrixWorldInverse ); 29 | 30 | this.projectionMatrix.copy( source.projectionMatrix ); 31 | this.projectionMatrixInverse.copy( source.projectionMatrixInverse ); 32 | 33 | this.coordinateSystem = source.coordinateSystem; 34 | 35 | return this; 36 | 37 | } 38 | 39 | getWorldDirection( target ) { 40 | 41 | this.updateWorldMatrix( true, false ); 42 | 43 | const e = this.matrixWorld.elements; 44 | 45 | return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize(); 46 | 47 | } 48 | 49 | updateMatrixWorld( force ) { 50 | 51 | super.updateMatrixWorld( force ); 52 | 53 | this.matrixWorldInverse.copy( this.matrixWorld ).invert(); 54 | 55 | } 56 | 57 | updateWorldMatrix( updateParents, updateChildren ) { 58 | 59 | super.updateWorldMatrix( updateParents, updateChildren ); 60 | 61 | this.matrixWorldInverse.copy( this.matrixWorld ).invert(); 62 | 63 | } 64 | 65 | clone() { 66 | 67 | return new this.constructor().copy( this ); 68 | 69 | } 70 | 71 | } 72 | 73 | export { Camera }; 74 | -------------------------------------------------------------------------------- /fixtures/threejs_src/scenes/Scene.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | 3 | class Scene extends Object3D { 4 | 5 | constructor() { 6 | 7 | super(); 8 | 9 | this.isScene = true; 10 | 11 | this.type = 'Scene'; 12 | 13 | this.background = null; 14 | this.environment = null; 15 | this.fog = null; 16 | 17 | this.backgroundBlurriness = 0; 18 | this.backgroundIntensity = 1; 19 | 20 | this.overrideMaterial = null; 21 | 22 | if ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) { 23 | 24 | __THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); 25 | 26 | } 27 | 28 | } 29 | 30 | copy( source, recursive ) { 31 | 32 | super.copy( source, recursive ); 33 | 34 | if ( source.background !== null ) this.background = source.background.clone(); 35 | if ( source.environment !== null ) this.environment = source.environment.clone(); 36 | if ( source.fog !== null ) this.fog = source.fog.clone(); 37 | 38 | this.backgroundBlurriness = source.backgroundBlurriness; 39 | this.backgroundIntensity = source.backgroundIntensity; 40 | 41 | if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone(); 42 | 43 | this.matrixAutoUpdate = source.matrixAutoUpdate; 44 | 45 | return this; 46 | 47 | } 48 | 49 | toJSON( meta ) { 50 | 51 | const data = super.toJSON( meta ); 52 | 53 | if ( this.fog !== null ) data.object.fog = this.fog.toJSON(); 54 | if ( this.backgroundBlurriness > 0 ) data.object.backgroundBlurriness = this.backgroundBlurriness; 55 | if ( this.backgroundIntensity !== 1 ) data.object.backgroundIntensity = this.backgroundIntensity; 56 | 57 | return data; 58 | 59 | } 60 | 61 | } 62 | 63 | export { Scene }; 64 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | 3 | #if NUM_SPOT_LIGHT_COORDS > 0 4 | 5 | uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; 6 | varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; 7 | 8 | #endif 9 | 10 | #ifdef USE_SHADOWMAP 11 | 12 | #if NUM_DIR_LIGHT_SHADOWS > 0 13 | 14 | uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; 15 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; 16 | 17 | struct DirectionalLightShadow { 18 | float shadowBias; 19 | float shadowNormalBias; 20 | float shadowRadius; 21 | vec2 shadowMapSize; 22 | }; 23 | 24 | uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; 25 | 26 | #endif 27 | 28 | #if NUM_SPOT_LIGHT_SHADOWS > 0 29 | 30 | struct SpotLightShadow { 31 | float shadowBias; 32 | float shadowNormalBias; 33 | float shadowRadius; 34 | vec2 shadowMapSize; 35 | }; 36 | 37 | uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; 38 | 39 | #endif 40 | 41 | #if NUM_POINT_LIGHT_SHADOWS > 0 42 | 43 | uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; 44 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; 45 | 46 | struct PointLightShadow { 47 | float shadowBias; 48 | float shadowNormalBias; 49 | float shadowRadius; 50 | vec2 shadowMapSize; 51 | float shadowCameraNear; 52 | float shadowCameraFar; 53 | }; 54 | 55 | uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; 56 | 57 | #endif 58 | 59 | /* 60 | #if NUM_RECT_AREA_LIGHTS > 0 61 | 62 | // TODO (abelnation): uniforms for area light shadows 63 | 64 | #endif 65 | */ 66 | 67 | #endif 68 | `; 69 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; 3 | 4 | #ifdef FLAT_SHADED 5 | 6 | vec3 fdx = dFdx( vViewPosition ); 7 | vec3 fdy = dFdy( vViewPosition ); 8 | vec3 normal = normalize( cross( fdx, fdy ) ); 9 | 10 | #else 11 | 12 | vec3 normal = normalize( vNormal ); 13 | 14 | #ifdef DOUBLE_SIDED 15 | 16 | normal *= faceDirection; 17 | 18 | #endif 19 | 20 | #endif 21 | 22 | #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) 23 | 24 | #ifdef USE_TANGENT 25 | 26 | mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 27 | 28 | #else 29 | 30 | mat3 tbn = getTangentFrame( - vViewPosition, normal, 31 | #if defined( USE_NORMALMAP ) 32 | vNormalMapUv 33 | #elif defined( USE_CLEARCOAT_NORMALMAP ) 34 | vClearcoatNormalMapUv 35 | #else 36 | vUv 37 | #endif 38 | ); 39 | 40 | #endif 41 | 42 | #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 43 | 44 | tbn[0] *= faceDirection; 45 | tbn[1] *= faceDirection; 46 | 47 | #endif 48 | 49 | #endif 50 | 51 | #ifdef USE_CLEARCOAT_NORMALMAP 52 | 53 | #ifdef USE_TANGENT 54 | 55 | mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); 56 | 57 | #else 58 | 59 | mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); 60 | 61 | #endif 62 | 63 | #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) 64 | 65 | tbn2[0] *= faceDirection; 66 | tbn2[1] *= faceDirection; 67 | 68 | #endif 69 | 70 | #endif 71 | 72 | // non perturbed normal for clearcoat among others 73 | 74 | vec3 geometryNormal = normal; 75 | 76 | `; 77 | -------------------------------------------------------------------------------- /fixtures/threejs_src/helpers/GridHelper.js: -------------------------------------------------------------------------------- 1 | import { LineSegments } from '../objects/LineSegments.js'; 2 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 3 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 4 | import { BufferGeometry } from '../core/BufferGeometry.js'; 5 | import { Color } from '../math/Color.js'; 6 | 7 | class GridHelper extends LineSegments { 8 | 9 | constructor( size = 10, divisions = 10, color1 = 0x444444, color2 = 0x888888 ) { 10 | 11 | color1 = new Color( color1 ); 12 | color2 = new Color( color2 ); 13 | 14 | const center = divisions / 2; 15 | const step = size / divisions; 16 | const halfSize = size / 2; 17 | 18 | const vertices = [], colors = []; 19 | 20 | for ( let i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) { 21 | 22 | vertices.push( - halfSize, 0, k, halfSize, 0, k ); 23 | vertices.push( k, 0, - halfSize, k, 0, halfSize ); 24 | 25 | const color = i === center ? color1 : color2; 26 | 27 | color.toArray( colors, j ); j += 3; 28 | color.toArray( colors, j ); j += 3; 29 | color.toArray( colors, j ); j += 3; 30 | color.toArray( colors, j ); j += 3; 31 | 32 | } 33 | 34 | const geometry = new BufferGeometry(); 35 | geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); 36 | geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); 37 | 38 | const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); 39 | 40 | super( geometry, material ); 41 | 42 | this.type = 'GridHelper'; 43 | 44 | } 45 | 46 | dispose() { 47 | 48 | this.geometry.dispose(); 49 | this.material.dispose(); 50 | 51 | } 52 | 53 | } 54 | 55 | 56 | export { GridHelper }; 57 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/LineCurve3.js: -------------------------------------------------------------------------------- 1 | import { Vector3 } from '../../math/Vector3.js'; 2 | import { Curve } from '../core/Curve.js'; 3 | 4 | class LineCurve3 extends Curve { 5 | 6 | constructor( v1 = new Vector3(), v2 = new Vector3() ) { 7 | 8 | super(); 9 | 10 | this.isLineCurve3 = true; 11 | 12 | this.type = 'LineCurve3'; 13 | 14 | this.v1 = v1; 15 | this.v2 = v2; 16 | 17 | } 18 | getPoint( t, optionalTarget = new Vector3() ) { 19 | 20 | const point = optionalTarget; 21 | 22 | if ( t === 1 ) { 23 | 24 | point.copy( this.v2 ); 25 | 26 | } else { 27 | 28 | point.copy( this.v2 ).sub( this.v1 ); 29 | point.multiplyScalar( t ).add( this.v1 ); 30 | 31 | } 32 | 33 | return point; 34 | 35 | } 36 | // Line curve is linear, so we can overwrite default getPointAt 37 | getPointAt( u, optionalTarget ) { 38 | 39 | return this.getPoint( u, optionalTarget ); 40 | 41 | } 42 | 43 | getTangent( t, optionalTarget = new Vector3() ) { 44 | 45 | return optionalTarget.subVectors( this.v2, this.v1 ).normalize(); 46 | 47 | } 48 | 49 | getTangentAt( u, optionalTarget ) { 50 | 51 | return this.getTangent( u, optionalTarget ); 52 | 53 | } 54 | 55 | copy( source ) { 56 | 57 | super.copy( source ); 58 | 59 | this.v1.copy( source.v1 ); 60 | this.v2.copy( source.v2 ); 61 | 62 | return this; 63 | 64 | } 65 | toJSON() { 66 | 67 | const data = super.toJSON(); 68 | 69 | data.v1 = this.v1.toArray(); 70 | data.v2 = this.v2.toArray(); 71 | 72 | return data; 73 | 74 | } 75 | fromJSON( json ) { 76 | 77 | super.fromJSON( json ); 78 | 79 | this.v1.fromArray( json.v1 ); 80 | this.v2.fromArray( json.v2 ); 81 | 82 | return this; 83 | 84 | } 85 | 86 | } 87 | 88 | export { LineCurve3 }; 89 | -------------------------------------------------------------------------------- /tests/magic_string_source_map.rs: -------------------------------------------------------------------------------- 1 | use string_wizard::{MagicString, SourceMapOptions, UpdateOptions}; 2 | 3 | #[test] 4 | fn basic() { 5 | let input = "
\n hello, world\n
"; 6 | let mut s = MagicString::new(input); 7 | let update_options = UpdateOptions { keep_original: true, ..Default::default() }; 8 | s.update_with(1, 2, "v", update_options.clone()) 9 | .update_with(3, 4, "d", update_options.clone()) 10 | .update_with(input.len() - 4, input.len() - 1, "h1", update_options.clone()); 11 | 12 | let sm = s.source_map(SourceMapOptions { include_content: true, ..Default::default() }); 13 | 14 | assert_eq!( 15 | sm.to_json_string(), 16 | "{\"version\":3,\"names\":[\"d\",\"v\",\"div\"],\"sources\":[\"\"],\"sourcesContent\":[\"
\\n hello, world\\n
\"],\"mappings\":\"AAAA,CAACA,CAAC,CAACC,CAAC;AACJ;AACA,EAAEC,EAAG\"}" 17 | ); 18 | 19 | s.prepend("import React from 'react';\n"); 20 | let sm = s.source_map(SourceMapOptions { include_content: true, ..Default::default() }); 21 | assert_eq!( 22 | sm.to_json_string(), 23 | "{\"version\":3,\"names\":[\"d\",\"v\",\"div\"],\"sources\":[\"\"],\"sourcesContent\":[\"
\\n hello, world\\n
\"],\"mappings\":\";AAAA,CAACA,CAAC,CAACC,CAAC;AACJ;AACA,EAAEC,EAAG\"}" 24 | ); 25 | 26 | let sm = 27 | s.source_map(SourceMapOptions { include_content: true, hires: true, ..Default::default() }); 28 | assert_eq!( 29 | sm.to_json_string(), 30 | "{\"version\":3,\"names\":[\"d\",\"v\",\"div\"],\"sources\":[\"\"],\"sourcesContent\":[\"
\\n hello, world\\n
\"],\"mappings\":\";AAAA,CAACA,CAAC,CAACC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACd,CAAC,CAACC,EAAG\"}" 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/CubicBezierCurve3.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { CubicBezier } from '../core/Interpolations.js'; 3 | import { Vector3 } from '../../math/Vector3.js'; 4 | 5 | class CubicBezierCurve3 extends Curve { 6 | 7 | constructor( v0 = new Vector3(), v1 = new Vector3(), v2 = new Vector3(), v3 = new Vector3() ) { 8 | 9 | super(); 10 | 11 | this.isCubicBezierCurve3 = true; 12 | 13 | this.type = 'CubicBezierCurve3'; 14 | 15 | this.v0 = v0; 16 | this.v1 = v1; 17 | this.v2 = v2; 18 | this.v3 = v3; 19 | 20 | } 21 | 22 | getPoint( t, optionalTarget = new Vector3() ) { 23 | 24 | const point = optionalTarget; 25 | 26 | const v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3; 27 | 28 | point.set( 29 | CubicBezier( t, v0.x, v1.x, v2.x, v3.x ), 30 | CubicBezier( t, v0.y, v1.y, v2.y, v3.y ), 31 | CubicBezier( t, v0.z, v1.z, v2.z, v3.z ) 32 | ); 33 | 34 | return point; 35 | 36 | } 37 | 38 | copy( source ) { 39 | 40 | super.copy( source ); 41 | 42 | this.v0.copy( source.v0 ); 43 | this.v1.copy( source.v1 ); 44 | this.v2.copy( source.v2 ); 45 | this.v3.copy( source.v3 ); 46 | 47 | return this; 48 | 49 | } 50 | 51 | toJSON() { 52 | 53 | const data = super.toJSON(); 54 | 55 | data.v0 = this.v0.toArray(); 56 | data.v1 = this.v1.toArray(); 57 | data.v2 = this.v2.toArray(); 58 | data.v3 = this.v3.toArray(); 59 | 60 | return data; 61 | 62 | } 63 | 64 | fromJSON( json ) { 65 | 66 | super.fromJSON( json ); 67 | 68 | this.v0.fromArray( json.v0 ); 69 | this.v1.fromArray( json.v1 ); 70 | this.v2.fromArray( json.v2 ); 71 | this.v3.fromArray( json.v3 ); 72 | 73 | return this; 74 | 75 | } 76 | 77 | } 78 | 79 | export { CubicBezierCurve3 }; 80 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/LineCurve.js: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../../math/Vector2.js'; 2 | import { Curve } from '../core/Curve.js'; 3 | 4 | class LineCurve extends Curve { 5 | 6 | constructor( v1 = new Vector2(), v2 = new Vector2() ) { 7 | 8 | super(); 9 | 10 | this.isLineCurve = true; 11 | 12 | this.type = 'LineCurve'; 13 | 14 | this.v1 = v1; 15 | this.v2 = v2; 16 | 17 | } 18 | 19 | getPoint( t, optionalTarget = new Vector2() ) { 20 | 21 | const point = optionalTarget; 22 | 23 | if ( t === 1 ) { 24 | 25 | point.copy( this.v2 ); 26 | 27 | } else { 28 | 29 | point.copy( this.v2 ).sub( this.v1 ); 30 | point.multiplyScalar( t ).add( this.v1 ); 31 | 32 | } 33 | 34 | return point; 35 | 36 | } 37 | 38 | // Line curve is linear, so we can overwrite default getPointAt 39 | getPointAt( u, optionalTarget ) { 40 | 41 | return this.getPoint( u, optionalTarget ); 42 | 43 | } 44 | 45 | getTangent( t, optionalTarget = new Vector2() ) { 46 | 47 | return optionalTarget.subVectors( this.v2, this.v1 ).normalize(); 48 | 49 | } 50 | 51 | getTangentAt( u, optionalTarget ) { 52 | 53 | return this.getTangent( u, optionalTarget ); 54 | 55 | } 56 | 57 | copy( source ) { 58 | 59 | super.copy( source ); 60 | 61 | this.v1.copy( source.v1 ); 62 | this.v2.copy( source.v2 ); 63 | 64 | return this; 65 | 66 | } 67 | 68 | toJSON() { 69 | 70 | const data = super.toJSON(); 71 | 72 | data.v1 = this.v1.toArray(); 73 | data.v2 = this.v2.toArray(); 74 | 75 | return data; 76 | 77 | } 78 | 79 | fromJSON( json ) { 80 | 81 | super.fromJSON( json ); 82 | 83 | this.v1.fromArray( json.v1 ); 84 | this.v2.fromArray( json.v2 ); 85 | 86 | return this; 87 | 88 | } 89 | 90 | } 91 | 92 | export { LineCurve }; 93 | -------------------------------------------------------------------------------- /fixtures/threejs_src/math/Spherical.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system 3 | * 4 | * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up. 5 | * The azimuthal angle (theta) is measured from the positive z-axis. 6 | */ 7 | 8 | import * as MathUtils from './MathUtils.js'; 9 | 10 | class Spherical { 11 | 12 | constructor( radius = 1, phi = 0, theta = 0 ) { 13 | 14 | this.radius = radius; 15 | this.phi = phi; // polar angle 16 | this.theta = theta; // azimuthal angle 17 | 18 | return this; 19 | 20 | } 21 | 22 | set( radius, phi, theta ) { 23 | 24 | this.radius = radius; 25 | this.phi = phi; 26 | this.theta = theta; 27 | 28 | return this; 29 | 30 | } 31 | 32 | copy( other ) { 33 | 34 | this.radius = other.radius; 35 | this.phi = other.phi; 36 | this.theta = other.theta; 37 | 38 | return this; 39 | 40 | } 41 | 42 | // restrict phi to be between EPS and PI-EPS 43 | makeSafe() { 44 | 45 | const EPS = 0.000001; 46 | this.phi = Math.max( EPS, Math.min( Math.PI - EPS, this.phi ) ); 47 | 48 | return this; 49 | 50 | } 51 | 52 | setFromVector3( v ) { 53 | 54 | return this.setFromCartesianCoords( v.x, v.y, v.z ); 55 | 56 | } 57 | 58 | setFromCartesianCoords( x, y, z ) { 59 | 60 | this.radius = Math.sqrt( x * x + y * y + z * z ); 61 | 62 | if ( this.radius === 0 ) { 63 | 64 | this.theta = 0; 65 | this.phi = 0; 66 | 67 | } else { 68 | 69 | this.theta = Math.atan2( x, z ); 70 | this.phi = Math.acos( MathUtils.clamp( y / this.radius, - 1, 1 ) ); 71 | 72 | } 73 | 74 | return this; 75 | 76 | } 77 | 78 | clone() { 79 | 80 | return new this.constructor().copy( this ); 81 | 82 | } 83 | 84 | } 85 | 86 | export { Spherical }; 87 | -------------------------------------------------------------------------------- /fixtures/threejs_src/helpers/AxesHelper.js: -------------------------------------------------------------------------------- 1 | import { LineSegments } from '../objects/LineSegments.js'; 2 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 3 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 4 | import { BufferGeometry } from '../core/BufferGeometry.js'; 5 | import { Color } from '../math/Color.js'; 6 | 7 | class AxesHelper extends LineSegments { 8 | 9 | constructor( size = 1 ) { 10 | 11 | const vertices = [ 12 | 0, 0, 0, size, 0, 0, 13 | 0, 0, 0, 0, size, 0, 14 | 0, 0, 0, 0, 0, size 15 | ]; 16 | 17 | const colors = [ 18 | 1, 0, 0, 1, 0.6, 0, 19 | 0, 1, 0, 0.6, 1, 0, 20 | 0, 0, 1, 0, 0.6, 1 21 | ]; 22 | 23 | const geometry = new BufferGeometry(); 24 | geometry.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); 25 | geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); 26 | 27 | const material = new LineBasicMaterial( { vertexColors: true, toneMapped: false } ); 28 | 29 | super( geometry, material ); 30 | 31 | this.type = 'AxesHelper'; 32 | 33 | } 34 | 35 | setColors( xAxisColor, yAxisColor, zAxisColor ) { 36 | 37 | const color = new Color(); 38 | const array = this.geometry.attributes.color.array; 39 | 40 | color.set( xAxisColor ); 41 | color.toArray( array, 0 ); 42 | color.toArray( array, 3 ); 43 | 44 | color.set( yAxisColor ); 45 | color.toArray( array, 6 ); 46 | color.toArray( array, 9 ); 47 | 48 | color.set( zAxisColor ); 49 | color.toArray( array, 12 ); 50 | color.toArray( array, 15 ); 51 | 52 | this.geometry.attributes.color.needsUpdate = true; 53 | 54 | return this; 55 | 56 | } 57 | 58 | dispose() { 59 | 60 | this.geometry.dispose(); 61 | this.material.dispose(); 62 | 63 | } 64 | 65 | } 66 | 67 | 68 | export { AxesHelper }; 69 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float getShadowMask() { 3 | 4 | float shadow = 1.0; 5 | 6 | #ifdef USE_SHADOWMAP 7 | 8 | #if NUM_DIR_LIGHT_SHADOWS > 0 9 | 10 | DirectionalLightShadow directionalLight; 11 | 12 | #pragma unroll_loop_start 13 | for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { 14 | 15 | directionalLight = directionalLightShadows[ i ]; 16 | shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 17 | 18 | } 19 | #pragma unroll_loop_end 20 | 21 | #endif 22 | 23 | #if NUM_SPOT_LIGHT_SHADOWS > 0 24 | 25 | SpotLightShadow spotLight; 26 | 27 | #pragma unroll_loop_start 28 | for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { 29 | 30 | spotLight = spotLightShadows[ i ]; 31 | shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; 32 | 33 | } 34 | #pragma unroll_loop_end 35 | 36 | #endif 37 | 38 | #if NUM_POINT_LIGHT_SHADOWS > 0 39 | 40 | PointLightShadow pointLight; 41 | 42 | #pragma unroll_loop_start 43 | for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { 44 | 45 | pointLight = pointLightShadows[ i ]; 46 | shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; 47 | 48 | } 49 | #pragma unroll_loop_end 50 | 51 | #endif 52 | 53 | /* 54 | #if NUM_RECT_AREA_LIGHTS > 0 55 | 56 | // TODO (abelnation): update shadow for Area light 57 | 58 | #endif 59 | */ 60 | 61 | #endif 62 | 63 | return shadow; 64 | 65 | } 66 | `; 67 | -------------------------------------------------------------------------------- /fixtures/threejs_src/core/EventDispatcher.js: -------------------------------------------------------------------------------- 1 | /** 2 | * https://github.com/mrdoob/eventdispatcher.js/ 3 | */ 4 | 5 | class EventDispatcher { 6 | 7 | addEventListener( type, listener ) { 8 | 9 | if ( this._listeners === undefined ) this._listeners = {}; 10 | 11 | const listeners = this._listeners; 12 | 13 | if ( listeners[ type ] === undefined ) { 14 | 15 | listeners[ type ] = []; 16 | 17 | } 18 | 19 | if ( listeners[ type ].indexOf( listener ) === - 1 ) { 20 | 21 | listeners[ type ].push( listener ); 22 | 23 | } 24 | 25 | } 26 | 27 | hasEventListener( type, listener ) { 28 | 29 | if ( this._listeners === undefined ) return false; 30 | 31 | const listeners = this._listeners; 32 | 33 | return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1; 34 | 35 | } 36 | 37 | removeEventListener( type, listener ) { 38 | 39 | if ( this._listeners === undefined ) return; 40 | 41 | const listeners = this._listeners; 42 | const listenerArray = listeners[ type ]; 43 | 44 | if ( listenerArray !== undefined ) { 45 | 46 | const index = listenerArray.indexOf( listener ); 47 | 48 | if ( index !== - 1 ) { 49 | 50 | listenerArray.splice( index, 1 ); 51 | 52 | } 53 | 54 | } 55 | 56 | } 57 | 58 | dispatchEvent( event ) { 59 | 60 | if ( this._listeners === undefined ) return; 61 | 62 | const listeners = this._listeners; 63 | const listenerArray = listeners[ event.type ]; 64 | 65 | if ( listenerArray !== undefined ) { 66 | 67 | event.target = this; 68 | 69 | // Make a copy, in case listeners are removed while iterating. 70 | const array = listenerArray.slice( 0 ); 71 | 72 | for ( let i = 0, l = array.length; i < l; i ++ ) { 73 | 74 | array[ i ].call( this, event ); 75 | 76 | } 77 | 78 | event.target = null; 79 | 80 | } 81 | 82 | } 83 | 84 | } 85 | 86 | 87 | export { EventDispatcher }; 88 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/linedashed.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | uniform float scale; 3 | attribute float lineDistance; 4 | 5 | varying float vLineDistance; 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | void main() { 16 | 17 | vLineDistance = scale * lineDistance; 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | } 30 | `; 31 | 32 | export const fragment = /* glsl */` 33 | uniform vec3 diffuse; 34 | uniform float opacity; 35 | 36 | uniform float dashSize; 37 | uniform float totalSize; 38 | 39 | varying float vLineDistance; 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | void main() { 50 | 51 | #include 52 | 53 | if ( mod( vLineDistance, totalSize ) > dashSize ) { 54 | 55 | discard; 56 | 57 | } 58 | 59 | vec3 outgoingLight = vec3( 0.0 ); 60 | vec4 diffuseColor = vec4( diffuse, opacity ); 61 | 62 | #include 63 | #include 64 | #include 65 | 66 | outgoingLight = diffuseColor.rgb; // simple shader 67 | 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | 74 | } 75 | `; 76 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/MeshMatcapMaterial.js: -------------------------------------------------------------------------------- 1 | import { TangentSpaceNormalMap } from '../constants.js'; 2 | import { Material } from './Material.js'; 3 | import { Vector2 } from '../math/Vector2.js'; 4 | import { Color } from '../math/Color.js'; 5 | 6 | class MeshMatcapMaterial extends Material { 7 | 8 | constructor( parameters ) { 9 | 10 | super(); 11 | 12 | this.isMeshMatcapMaterial = true; 13 | 14 | this.defines = { 'MATCAP': '' }; 15 | 16 | this.type = 'MeshMatcapMaterial'; 17 | 18 | this.color = new Color( 0xffffff ); // diffuse 19 | 20 | this.matcap = null; 21 | 22 | this.map = null; 23 | 24 | this.bumpMap = null; 25 | this.bumpScale = 1; 26 | 27 | this.normalMap = null; 28 | this.normalMapType = TangentSpaceNormalMap; 29 | this.normalScale = new Vector2( 1, 1 ); 30 | 31 | this.displacementMap = null; 32 | this.displacementScale = 1; 33 | this.displacementBias = 0; 34 | 35 | this.alphaMap = null; 36 | 37 | this.flatShading = false; 38 | 39 | this.fog = true; 40 | 41 | this.setValues( parameters ); 42 | 43 | } 44 | 45 | 46 | copy( source ) { 47 | 48 | super.copy( source ); 49 | 50 | this.defines = { 'MATCAP': '' }; 51 | 52 | this.color.copy( source.color ); 53 | 54 | this.matcap = source.matcap; 55 | 56 | this.map = source.map; 57 | 58 | this.bumpMap = source.bumpMap; 59 | this.bumpScale = source.bumpScale; 60 | 61 | this.normalMap = source.normalMap; 62 | this.normalMapType = source.normalMapType; 63 | this.normalScale.copy( source.normalScale ); 64 | 65 | this.displacementMap = source.displacementMap; 66 | this.displacementScale = source.displacementScale; 67 | this.displacementBias = source.displacementBias; 68 | 69 | this.alphaMap = source.alphaMap; 70 | 71 | this.flatShading = source.flatShading; 72 | 73 | this.fog = source.fog; 74 | 75 | return this; 76 | 77 | } 78 | 79 | } 80 | 81 | export { MeshMatcapMaterial }; 82 | -------------------------------------------------------------------------------- /fixtures/threejs_src/loaders/ImageLoader.js: -------------------------------------------------------------------------------- 1 | import { Cache } from './Cache.js'; 2 | import { Loader } from './Loader.js'; 3 | import { createElementNS } from '../utils.js'; 4 | 5 | class ImageLoader extends Loader { 6 | 7 | constructor( manager ) { 8 | 9 | super( manager ); 10 | 11 | } 12 | 13 | load( url, onLoad, onProgress, onError ) { 14 | 15 | if ( this.path !== undefined ) url = this.path + url; 16 | 17 | url = this.manager.resolveURL( url ); 18 | 19 | const scope = this; 20 | 21 | const cached = Cache.get( url ); 22 | 23 | if ( cached !== undefined ) { 24 | 25 | scope.manager.itemStart( url ); 26 | 27 | setTimeout( function () { 28 | 29 | if ( onLoad ) onLoad( cached ); 30 | 31 | scope.manager.itemEnd( url ); 32 | 33 | }, 0 ); 34 | 35 | return cached; 36 | 37 | } 38 | 39 | const image = createElementNS( 'img' ); 40 | 41 | function onImageLoad() { 42 | 43 | removeEventListeners(); 44 | 45 | Cache.add( url, this ); 46 | 47 | if ( onLoad ) onLoad( this ); 48 | 49 | scope.manager.itemEnd( url ); 50 | 51 | } 52 | 53 | function onImageError( event ) { 54 | 55 | removeEventListeners(); 56 | 57 | if ( onError ) onError( event ); 58 | 59 | scope.manager.itemError( url ); 60 | scope.manager.itemEnd( url ); 61 | 62 | } 63 | 64 | function removeEventListeners() { 65 | 66 | image.removeEventListener( 'load', onImageLoad, false ); 67 | image.removeEventListener( 'error', onImageError, false ); 68 | 69 | } 70 | 71 | image.addEventListener( 'load', onImageLoad, false ); 72 | image.addEventListener( 'error', onImageError, false ); 73 | 74 | if ( url.slice( 0, 5 ) !== 'data:' ) { 75 | 76 | if ( this.crossOrigin !== undefined ) image.crossOrigin = this.crossOrigin; 77 | 78 | } 79 | 80 | scope.manager.itemStart( url ); 81 | 82 | image.src = url; 83 | 84 | return image; 85 | 86 | } 87 | 88 | } 89 | 90 | 91 | export { ImageLoader }; 92 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | #define DISTANCE 3 | 4 | varying vec3 vWorldPosition; 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void main() { 14 | 15 | #include 16 | 17 | #include 18 | 19 | #ifdef USE_DISPLACEMENTMAP 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | vWorldPosition = worldPosition.xyz; 36 | 37 | } 38 | `; 39 | 40 | export const fragment = /* glsl */` 41 | #define DISTANCE 42 | 43 | uniform vec3 referencePosition; 44 | uniform float nearDistance; 45 | uniform float farDistance; 46 | varying vec3 vWorldPosition; 47 | 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | 57 | void main () { 58 | 59 | #include 60 | 61 | vec4 diffuseColor = vec4( 1.0 ); 62 | 63 | #include 64 | #include 65 | #include 66 | #include 67 | 68 | float dist = length( vWorldPosition - referencePosition ); 69 | dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); 70 | dist = saturate( dist ); // clamp to [ 0, 1 ] 71 | 72 | gl_FragColor = packDepthToRGBA( dist ); 73 | 74 | } 75 | `; 76 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/ShapeUtils.js: -------------------------------------------------------------------------------- 1 | import { Earcut } from './Earcut.js'; 2 | 3 | class ShapeUtils { 4 | 5 | // calculate area of the contour polygon 6 | 7 | static area( contour ) { 8 | 9 | const n = contour.length; 10 | let a = 0.0; 11 | 12 | for ( let p = n - 1, q = 0; q < n; p = q ++ ) { 13 | 14 | a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; 15 | 16 | } 17 | 18 | return a * 0.5; 19 | 20 | } 21 | 22 | static isClockWise( pts ) { 23 | 24 | return ShapeUtils.area( pts ) < 0; 25 | 26 | } 27 | 28 | static triangulateShape( contour, holes ) { 29 | 30 | const vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ] 31 | const holeIndices = []; // array of hole indices 32 | const faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ] 33 | 34 | removeDupEndPts( contour ); 35 | addContour( vertices, contour ); 36 | 37 | // 38 | 39 | let holeIndex = contour.length; 40 | 41 | holes.forEach( removeDupEndPts ); 42 | 43 | for ( let i = 0; i < holes.length; i ++ ) { 44 | 45 | holeIndices.push( holeIndex ); 46 | holeIndex += holes[ i ].length; 47 | addContour( vertices, holes[ i ] ); 48 | 49 | } 50 | 51 | // 52 | 53 | const triangles = Earcut.triangulate( vertices, holeIndices ); 54 | 55 | // 56 | 57 | for ( let i = 0; i < triangles.length; i += 3 ) { 58 | 59 | faces.push( triangles.slice( i, i + 3 ) ); 60 | 61 | } 62 | 63 | return faces; 64 | 65 | } 66 | 67 | } 68 | 69 | function removeDupEndPts( points ) { 70 | 71 | const l = points.length; 72 | 73 | if ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) { 74 | 75 | points.pop(); 76 | 77 | } 78 | 79 | } 80 | 81 | function addContour( vertices, contour ) { 82 | 83 | for ( let i = 0; i < contour.length; i ++ ) { 84 | 85 | vertices.push( contour[ i ].x ); 86 | vertices.push( contour[ i ].y ); 87 | 88 | } 89 | 90 | } 91 | 92 | export { ShapeUtils }; 93 | -------------------------------------------------------------------------------- /fixtures/threejs_src/utils.js: -------------------------------------------------------------------------------- 1 | function arrayMin( array ) { 2 | 3 | if ( array.length === 0 ) return Infinity; 4 | 5 | let min = array[ 0 ]; 6 | 7 | for ( let i = 1, l = array.length; i < l; ++ i ) { 8 | 9 | if ( array[ i ] < min ) min = array[ i ]; 10 | 11 | } 12 | 13 | return min; 14 | 15 | } 16 | 17 | function arrayMax( array ) { 18 | 19 | if ( array.length === 0 ) return - Infinity; 20 | 21 | let max = array[ 0 ]; 22 | 23 | for ( let i = 1, l = array.length; i < l; ++ i ) { 24 | 25 | if ( array[ i ] > max ) max = array[ i ]; 26 | 27 | } 28 | 29 | return max; 30 | 31 | } 32 | 33 | function arrayNeedsUint32( array ) { 34 | 35 | // assumes larger values usually on last 36 | 37 | for ( let i = array.length - 1; i >= 0; -- i ) { 38 | 39 | if ( array[ i ] >= 65535 ) return true; // account for PRIMITIVE_RESTART_FIXED_INDEX, #24565 40 | 41 | } 42 | 43 | return false; 44 | 45 | } 46 | 47 | const TYPED_ARRAYS = { 48 | Int8Array: Int8Array, 49 | Uint8Array: Uint8Array, 50 | Uint8ClampedArray: Uint8ClampedArray, 51 | Int16Array: Int16Array, 52 | Uint16Array: Uint16Array, 53 | Int32Array: Int32Array, 54 | Uint32Array: Uint32Array, 55 | Float32Array: Float32Array, 56 | Float64Array: Float64Array 57 | }; 58 | 59 | function getTypedArray( type, buffer ) { 60 | 61 | return new TYPED_ARRAYS[ type ]( buffer ); 62 | 63 | } 64 | 65 | function createElementNS( name ) { 66 | 67 | return document.createElementNS( 'http://www.w3.org/1999/xhtml', name ); 68 | 69 | } 70 | 71 | function createCanvasElement() { 72 | 73 | const canvas = createElementNS( 'canvas' ); 74 | canvas.style.display = 'block'; 75 | return canvas; 76 | 77 | } 78 | 79 | const _cache = {}; 80 | 81 | function warnOnce( message ) { 82 | 83 | if ( message in _cache ) return; 84 | 85 | _cache[ message ] = true; 86 | 87 | console.warn( message ); 88 | 89 | } 90 | 91 | export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce }; 92 | -------------------------------------------------------------------------------- /fixtures/threejs_src/materials/MeshBasicMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { MultiplyOperation } from '../constants.js'; 3 | import { Color } from '../math/Color.js'; 4 | 5 | class MeshBasicMaterial extends Material { 6 | 7 | constructor( parameters ) { 8 | 9 | super(); 10 | 11 | this.isMeshBasicMaterial = true; 12 | 13 | this.type = 'MeshBasicMaterial'; 14 | 15 | this.color = new Color( 0xffffff ); // emissive 16 | 17 | this.map = null; 18 | 19 | this.lightMap = null; 20 | this.lightMapIntensity = 1.0; 21 | 22 | this.aoMap = null; 23 | this.aoMapIntensity = 1.0; 24 | 25 | this.specularMap = null; 26 | 27 | this.alphaMap = null; 28 | 29 | this.envMap = null; 30 | this.combine = MultiplyOperation; 31 | this.reflectivity = 1; 32 | this.refractionRatio = 0.98; 33 | 34 | this.wireframe = false; 35 | this.wireframeLinewidth = 1; 36 | this.wireframeLinecap = 'round'; 37 | this.wireframeLinejoin = 'round'; 38 | 39 | this.fog = true; 40 | 41 | this.setValues( parameters ); 42 | 43 | } 44 | 45 | copy( source ) { 46 | 47 | super.copy( source ); 48 | 49 | this.color.copy( source.color ); 50 | 51 | this.map = source.map; 52 | 53 | this.lightMap = source.lightMap; 54 | this.lightMapIntensity = source.lightMapIntensity; 55 | 56 | this.aoMap = source.aoMap; 57 | this.aoMapIntensity = source.aoMapIntensity; 58 | 59 | this.specularMap = source.specularMap; 60 | 61 | this.alphaMap = source.alphaMap; 62 | 63 | this.envMap = source.envMap; 64 | this.combine = source.combine; 65 | this.reflectivity = source.reflectivity; 66 | this.refractionRatio = source.refractionRatio; 67 | 68 | this.wireframe = source.wireframe; 69 | this.wireframeLinewidth = source.wireframeLinewidth; 70 | this.wireframeLinecap = source.wireframeLinecap; 71 | this.wireframeLinejoin = source.wireframeLinejoin; 72 | 73 | this.fog = source.fog; 74 | 75 | return this; 76 | 77 | } 78 | 79 | } 80 | 81 | export { MeshBasicMaterial }; 82 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/core/Shape.js: -------------------------------------------------------------------------------- 1 | import { Path } from './Path.js'; 2 | import * as MathUtils from '../../math/MathUtils.js'; 3 | 4 | class Shape extends Path { 5 | 6 | constructor( points ) { 7 | 8 | super( points ); 9 | 10 | this.uuid = MathUtils.generateUUID(); 11 | 12 | this.type = 'Shape'; 13 | 14 | this.holes = []; 15 | 16 | } 17 | 18 | getPointsHoles( divisions ) { 19 | 20 | const holesPts = []; 21 | 22 | for ( let i = 0, l = this.holes.length; i < l; i ++ ) { 23 | 24 | holesPts[ i ] = this.holes[ i ].getPoints( divisions ); 25 | 26 | } 27 | 28 | return holesPts; 29 | 30 | } 31 | 32 | // get points of shape and holes (keypoints based on segments parameter) 33 | 34 | extractPoints( divisions ) { 35 | 36 | return { 37 | 38 | shape: this.getPoints( divisions ), 39 | holes: this.getPointsHoles( divisions ) 40 | 41 | }; 42 | 43 | } 44 | 45 | copy( source ) { 46 | 47 | super.copy( source ); 48 | 49 | this.holes = []; 50 | 51 | for ( let i = 0, l = source.holes.length; i < l; i ++ ) { 52 | 53 | const hole = source.holes[ i ]; 54 | 55 | this.holes.push( hole.clone() ); 56 | 57 | } 58 | 59 | return this; 60 | 61 | } 62 | 63 | toJSON() { 64 | 65 | const data = super.toJSON(); 66 | 67 | data.uuid = this.uuid; 68 | data.holes = []; 69 | 70 | for ( let i = 0, l = this.holes.length; i < l; i ++ ) { 71 | 72 | const hole = this.holes[ i ]; 73 | data.holes.push( hole.toJSON() ); 74 | 75 | } 76 | 77 | return data; 78 | 79 | } 80 | 81 | fromJSON( json ) { 82 | 83 | super.fromJSON( json ); 84 | 85 | this.uuid = json.uuid; 86 | this.holes = []; 87 | 88 | for ( let i = 0, l = json.holes.length; i < l; i ++ ) { 89 | 90 | const hole = json.holes[ i ]; 91 | this.holes.push( new Path().fromJSON( hole ) ); 92 | 93 | } 94 | 95 | return this; 96 | 97 | } 98 | 99 | } 100 | 101 | 102 | export { Shape }; 103 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/webgl/WebGLObjects.js: -------------------------------------------------------------------------------- 1 | function WebGLObjects( gl, geometries, attributes, info ) { 2 | 3 | let updateMap = new WeakMap(); 4 | 5 | function update( object ) { 6 | 7 | const frame = info.render.frame; 8 | 9 | const geometry = object.geometry; 10 | const buffergeometry = geometries.get( object, geometry ); 11 | 12 | // Update once per frame 13 | 14 | if ( updateMap.get( buffergeometry ) !== frame ) { 15 | 16 | geometries.update( buffergeometry ); 17 | 18 | updateMap.set( buffergeometry, frame ); 19 | 20 | } 21 | 22 | if ( object.isInstancedMesh ) { 23 | 24 | if ( object.hasEventListener( 'dispose', onInstancedMeshDispose ) === false ) { 25 | 26 | object.addEventListener( 'dispose', onInstancedMeshDispose ); 27 | 28 | } 29 | 30 | if ( updateMap.get( object ) !== frame ) { 31 | 32 | attributes.update( object.instanceMatrix, gl.ARRAY_BUFFER ); 33 | 34 | if ( object.instanceColor !== null ) { 35 | 36 | attributes.update( object.instanceColor, gl.ARRAY_BUFFER ); 37 | 38 | } 39 | 40 | updateMap.set( object, frame ); 41 | 42 | } 43 | 44 | } 45 | 46 | if ( object.isSkinnedMesh ) { 47 | 48 | const skeleton = object.skeleton; 49 | 50 | if ( updateMap.get( skeleton ) !== frame ) { 51 | 52 | skeleton.update(); 53 | 54 | updateMap.set( skeleton, frame ); 55 | 56 | } 57 | 58 | } 59 | 60 | return buffergeometry; 61 | 62 | } 63 | 64 | function dispose() { 65 | 66 | updateMap = new WeakMap(); 67 | 68 | } 69 | 70 | function onInstancedMeshDispose( event ) { 71 | 72 | const instancedMesh = event.target; 73 | 74 | instancedMesh.removeEventListener( 'dispose', onInstancedMeshDispose ); 75 | 76 | attributes.remove( instancedMesh.instanceMatrix ); 77 | 78 | if ( instancedMesh.instanceColor !== null ) attributes.remove( instancedMesh.instanceColor ); 79 | 80 | } 81 | 82 | return { 83 | 84 | update: update, 85 | dispose: dispose 86 | 87 | }; 88 | 89 | } 90 | 91 | 92 | export { WebGLObjects }; 93 | -------------------------------------------------------------------------------- /fixtures/threejs_src/helpers/PlaneHelper.js: -------------------------------------------------------------------------------- 1 | import { Line } from '../objects/Line.js'; 2 | import { Mesh } from '../objects/Mesh.js'; 3 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 4 | import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; 5 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 6 | import { BufferGeometry } from '../core/BufferGeometry.js'; 7 | 8 | class PlaneHelper extends Line { 9 | 10 | constructor( plane, size = 1, hex = 0xffff00 ) { 11 | 12 | const color = hex; 13 | 14 | const positions = [ 1, - 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, - 1, 0, 1, 1, 0 ]; 15 | 16 | const geometry = new BufferGeometry(); 17 | geometry.setAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); 18 | geometry.computeBoundingSphere(); 19 | 20 | super( geometry, new LineBasicMaterial( { color: color, toneMapped: false } ) ); 21 | 22 | this.type = 'PlaneHelper'; 23 | 24 | this.plane = plane; 25 | 26 | this.size = size; 27 | 28 | const positions2 = [ 1, 1, 0, - 1, 1, 0, - 1, - 1, 0, 1, 1, 0, - 1, - 1, 0, 1, - 1, 0 ]; 29 | 30 | const geometry2 = new BufferGeometry(); 31 | geometry2.setAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); 32 | geometry2.computeBoundingSphere(); 33 | 34 | this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false, toneMapped: false } ) ) ); 35 | 36 | } 37 | 38 | updateMatrixWorld( force ) { 39 | 40 | this.position.set( 0, 0, 0 ); 41 | 42 | this.scale.set( 0.5 * this.size, 0.5 * this.size, 1 ); 43 | 44 | this.lookAt( this.plane.normal ); 45 | 46 | this.translateZ( - this.plane.constant ); 47 | 48 | super.updateMatrixWorld( force ); 49 | 50 | } 51 | 52 | dispose() { 53 | 54 | this.geometry.dispose(); 55 | this.material.dispose(); 56 | this.children[ 0 ].geometry.dispose(); 57 | this.children[ 0 ].material.dispose(); 58 | 59 | } 60 | 61 | } 62 | 63 | export { PlaneHelper }; 64 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | vec3 getIBLIrradiance( const in vec3 normal ) { 5 | 6 | #ifdef ENVMAP_TYPE_CUBE_UV 7 | 8 | vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 9 | 10 | vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 ); 11 | 12 | return PI * envMapColor.rgb * envMapIntensity; 13 | 14 | #else 15 | 16 | return vec3( 0.0 ); 17 | 18 | #endif 19 | 20 | } 21 | 22 | vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { 23 | 24 | #ifdef ENVMAP_TYPE_CUBE_UV 25 | 26 | vec3 reflectVec = reflect( - viewDir, normal ); 27 | 28 | // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane. 29 | reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); 30 | 31 | reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); 32 | 33 | vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness ); 34 | 35 | return envMapColor.rgb * envMapIntensity; 36 | 37 | #else 38 | 39 | return vec3( 0.0 ); 40 | 41 | #endif 42 | 43 | } 44 | 45 | #ifdef USE_ANISOTROPY 46 | 47 | vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { 48 | 49 | #ifdef ENVMAP_TYPE_CUBE_UV 50 | 51 | // https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy 52 | vec3 bentNormal = cross( bitangent, viewDir ); 53 | bentNormal = normalize( cross( bentNormal, bitangent ) ); 54 | bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); 55 | 56 | return getIBLRadiance( viewDir, bentNormal, roughness ); 57 | 58 | #else 59 | 60 | return vec3( 0.0 ); 61 | 62 | #endif 63 | 64 | } 65 | 66 | #endif 67 | 68 | #endif 69 | `; 70 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/WebGLMultipleRenderTargets.js: -------------------------------------------------------------------------------- 1 | import { WebGLRenderTarget } from './WebGLRenderTarget.js'; 2 | 3 | class WebGLMultipleRenderTargets extends WebGLRenderTarget { 4 | 5 | constructor( width = 1, height = 1, count = 1, options = {} ) { 6 | 7 | super( width, height, options ); 8 | 9 | this.isWebGLMultipleRenderTargets = true; 10 | 11 | const texture = this.texture; 12 | 13 | this.texture = []; 14 | 15 | for ( let i = 0; i < count; i ++ ) { 16 | 17 | this.texture[ i ] = texture.clone(); 18 | this.texture[ i ].isRenderTargetTexture = true; 19 | 20 | } 21 | 22 | } 23 | 24 | setSize( width, height, depth = 1 ) { 25 | 26 | if ( this.width !== width || this.height !== height || this.depth !== depth ) { 27 | 28 | this.width = width; 29 | this.height = height; 30 | this.depth = depth; 31 | 32 | for ( let i = 0, il = this.texture.length; i < il; i ++ ) { 33 | 34 | this.texture[ i ].image.width = width; 35 | this.texture[ i ].image.height = height; 36 | this.texture[ i ].image.depth = depth; 37 | 38 | } 39 | 40 | this.dispose(); 41 | 42 | } 43 | 44 | this.viewport.set( 0, 0, width, height ); 45 | this.scissor.set( 0, 0, width, height ); 46 | 47 | } 48 | 49 | copy( source ) { 50 | 51 | this.dispose(); 52 | 53 | this.width = source.width; 54 | this.height = source.height; 55 | this.depth = source.depth; 56 | 57 | this.scissor.copy( source.scissor ); 58 | this.scissorTest = source.scissorTest; 59 | 60 | this.viewport.copy( source.viewport ); 61 | 62 | this.depthBuffer = source.depthBuffer; 63 | this.stencilBuffer = source.stencilBuffer; 64 | 65 | if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone(); 66 | 67 | this.texture.length = 0; 68 | 69 | for ( let i = 0, il = source.texture.length; i < il; i ++ ) { 70 | 71 | this.texture[ i ] = source.texture[ i ].clone(); 72 | this.texture[ i ].isRenderTargetTexture = true; 73 | 74 | } 75 | 76 | return this; 77 | 78 | } 79 | 80 | } 81 | 82 | export { WebGLMultipleRenderTargets }; 83 | -------------------------------------------------------------------------------- /fixtures/threejs_src/renderers/shaders/ShaderLib/meshnormal.glsl.js: -------------------------------------------------------------------------------- 1 | export const vertex = /* glsl */` 2 | #define NORMAL 3 | 4 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 5 | 6 | varying vec3 vViewPosition; 7 | 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | void main() { 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 39 | 40 | vViewPosition = - mvPosition.xyz; 41 | 42 | #endif 43 | 44 | } 45 | `; 46 | 47 | export const fragment = /* glsl */` 48 | #define NORMAL 49 | 50 | uniform float opacity; 51 | 52 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) 53 | 54 | varying vec3 vViewPosition; 55 | 56 | #endif 57 | 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | void main() { 67 | 68 | #include 69 | #include 70 | #include 71 | #include 72 | 73 | gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); 74 | 75 | #ifdef OPAQUE 76 | 77 | gl_FragColor.a = 1.0; 78 | 79 | #endif 80 | 81 | } 82 | `; 83 | -------------------------------------------------------------------------------- /fixtures/threejs_src/extras/curves/SplineCurve.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { CatmullRom } from '../core/Interpolations.js'; 3 | import { Vector2 } from '../../math/Vector2.js'; 4 | 5 | class SplineCurve extends Curve { 6 | 7 | constructor( points = [] ) { 8 | 9 | super(); 10 | 11 | this.isSplineCurve = true; 12 | 13 | this.type = 'SplineCurve'; 14 | 15 | this.points = points; 16 | 17 | } 18 | 19 | getPoint( t, optionalTarget = new Vector2() ) { 20 | 21 | const point = optionalTarget; 22 | 23 | const points = this.points; 24 | const p = ( points.length - 1 ) * t; 25 | 26 | const intPoint = Math.floor( p ); 27 | const weight = p - intPoint; 28 | 29 | const p0 = points[ intPoint === 0 ? intPoint : intPoint - 1 ]; 30 | const p1 = points[ intPoint ]; 31 | const p2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ]; 32 | const p3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ]; 33 | 34 | point.set( 35 | CatmullRom( weight, p0.x, p1.x, p2.x, p3.x ), 36 | CatmullRom( weight, p0.y, p1.y, p2.y, p3.y ) 37 | ); 38 | 39 | return point; 40 | 41 | } 42 | 43 | copy( source ) { 44 | 45 | super.copy( source ); 46 | 47 | this.points = []; 48 | 49 | for ( let i = 0, l = source.points.length; i < l; i ++ ) { 50 | 51 | const point = source.points[ i ]; 52 | 53 | this.points.push( point.clone() ); 54 | 55 | } 56 | 57 | return this; 58 | 59 | } 60 | 61 | toJSON() { 62 | 63 | const data = super.toJSON(); 64 | 65 | data.points = []; 66 | 67 | for ( let i = 0, l = this.points.length; i < l; i ++ ) { 68 | 69 | const point = this.points[ i ]; 70 | data.points.push( point.toArray() ); 71 | 72 | } 73 | 74 | return data; 75 | 76 | } 77 | 78 | fromJSON( json ) { 79 | 80 | super.fromJSON( json ); 81 | 82 | this.points = []; 83 | 84 | for ( let i = 0, l = json.points.length; i < l; i ++ ) { 85 | 86 | const point = json.points[ i ]; 87 | this.points.push( new Vector2().fromArray( point ) ); 88 | 89 | } 90 | 91 | return this; 92 | 93 | } 94 | 95 | } 96 | 97 | export { SplineCurve }; 98 | --------------------------------------------------------------------------------