super-three 0.168.0 → 0.169.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/build/three.cjs +384 -700
  2. package/build/three.module.js +384 -700
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +24644 -22406
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +79941 -0
  7. package/build/three.webgpu.nodes.min.js +6 -0
  8. package/examples/jsm/Addons.js +0 -6
  9. package/examples/jsm/controls/TrackballControls.js +32 -12
  10. package/examples/jsm/controls/TransformControls.js +97 -62
  11. package/examples/jsm/exporters/DRACOExporter.js +4 -2
  12. package/examples/jsm/exporters/EXRExporter.js +19 -11
  13. package/examples/jsm/exporters/KTX2Exporter.js +21 -13
  14. package/examples/jsm/exporters/OBJExporter.js +5 -1
  15. package/examples/jsm/exporters/PLYExporter.js +9 -7
  16. package/examples/jsm/geometries/DecalGeometry.js +4 -1
  17. package/examples/jsm/geometries/InstancedPointsGeometry.js +1 -1
  18. package/examples/jsm/helpers/LightProbeHelper.js +1 -1
  19. package/examples/jsm/helpers/LightProbeHelperGPU.js +65 -0
  20. package/examples/jsm/libs/basis/basis_transcoder.js +8 -10
  21. package/examples/jsm/libs/basis/basis_transcoder.wasm +0 -0
  22. package/examples/jsm/libs/ktx-parse.module.js +1 -1
  23. package/examples/jsm/lights/LightProbeGenerator.js +24 -10
  24. package/examples/jsm/loaders/ColladaLoader.js +9 -6
  25. package/examples/jsm/loaders/DRACOLoader.js +3 -1
  26. package/examples/jsm/loaders/FBXLoader.js +30 -20
  27. package/examples/jsm/loaders/GLTFLoader.js +5 -10
  28. package/examples/jsm/loaders/KTX2Loader.js +10 -7
  29. package/examples/jsm/loaders/MTLLoader.js +4 -3
  30. package/examples/jsm/loaders/MaterialXLoader.js +29 -10
  31. package/examples/jsm/loaders/OBJLoader.js +5 -3
  32. package/examples/jsm/loaders/PCDLoader.js +5 -4
  33. package/examples/jsm/loaders/PDBLoader.js +3 -2
  34. package/examples/jsm/loaders/PLYLoader.js +8 -5
  35. package/examples/jsm/loaders/STLLoader.js +3 -2
  36. package/examples/jsm/loaders/VRMLLoader.js +10 -10
  37. package/examples/jsm/loaders/VTKLoader.js +4 -3
  38. package/examples/jsm/loaders/XYZLoader.js +3 -2
  39. package/examples/jsm/misc/Timer.js +1 -1
  40. package/examples/jsm/modifiers/CurveModifierGPU.js +233 -0
  41. package/examples/jsm/objects/LensflareMesh.js +322 -0
  42. package/examples/jsm/objects/SkyMesh.js +1 -2
  43. package/examples/jsm/objects/Water2Mesh.js +2 -3
  44. package/examples/jsm/objects/WaterMesh.js +1 -2
  45. package/examples/jsm/physics/JoltPhysics.js +1 -1
  46. package/examples/jsm/physics/RapierPhysics.js +1 -1
  47. package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
  48. package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -2
  49. package/examples/jsm/utils/GeometryCompressionUtils.js +37 -122
  50. package/examples/jsm/utils/ShadowMapViewer.js +3 -8
  51. package/examples/jsm/utils/ShadowMapViewerGPU.js +201 -0
  52. package/examples/jsm/utils/SkeletonUtils.js +84 -66
  53. package/examples/jsm/utils/TextureUtils.js +1 -0
  54. package/examples/jsm/utils/TextureUtilsGPU.js +63 -0
  55. package/examples/jsm/webxr/XRControllerModelFactory.js +1 -1
  56. package/package.json +2 -2
  57. package/src/Three.WebGPU.Nodes.js +200 -0
  58. package/src/Three.WebGPU.js +2 -1
  59. package/src/audio/Audio.js +2 -2
  60. package/src/constants.js +1 -1
  61. package/src/core/BufferAttribute.js +0 -9
  62. package/src/core/Clock.js +1 -1
  63. package/src/core/InterleavedBuffer.js +0 -9
  64. package/src/extras/Controls.js +1 -1
  65. package/src/geometries/CylinderGeometry.js +11 -4
  66. package/src/loaders/MaterialLoader.js +7 -1
  67. package/src/loaders/nodes/NodeLoader.js +24 -4
  68. package/src/loaders/nodes/NodeMaterialLoader.js +21 -17
  69. package/src/loaders/nodes/NodeObjectLoader.js +19 -0
  70. package/src/materials/nodes/InstancedPointsNodeMaterial.js +19 -34
  71. package/src/materials/nodes/Line2NodeMaterial.js +26 -26
  72. package/src/materials/nodes/LineBasicNodeMaterial.js +7 -3
  73. package/src/materials/nodes/LineDashedNodeMaterial.js +7 -3
  74. package/src/materials/nodes/MeshBasicNodeMaterial.js +7 -3
  75. package/src/materials/nodes/MeshLambertNodeMaterial.js +7 -3
  76. package/src/materials/nodes/MeshMatcapNodeMaterial.js +7 -3
  77. package/src/materials/nodes/MeshNormalNodeMaterial.js +7 -3
  78. package/src/materials/nodes/MeshPhongNodeMaterial.js +7 -3
  79. package/src/materials/nodes/MeshPhysicalNodeMaterial.js +6 -3
  80. package/src/materials/nodes/MeshSSSNodeMaterial.js +6 -3
  81. package/src/materials/nodes/MeshStandardNodeMaterial.js +7 -3
  82. package/src/materials/nodes/MeshToonNodeMaterial.js +7 -3
  83. package/src/materials/nodes/NodeMaterial.js +20 -45
  84. package/src/materials/nodes/NodeMaterials.js +2 -0
  85. package/src/materials/nodes/PointsNodeMaterial.js +7 -3
  86. package/src/materials/nodes/ShadowNodeMaterial.js +7 -3
  87. package/src/materials/nodes/SpriteNodeMaterial.js +39 -6
  88. package/src/materials/nodes/VolumeNodeMaterial.js +13 -9
  89. package/src/materials/nodes/manager/NodeMaterialObserver.js +302 -0
  90. package/src/math/Triangle.js +24 -0
  91. package/src/nodes/Nodes.js +3 -3
  92. package/src/nodes/TSL.js +96 -93
  93. package/src/nodes/accessors/BatchNode.js +7 -3
  94. package/src/nodes/accessors/BufferAttributeNode.js +6 -3
  95. package/src/nodes/accessors/BufferNode.js +6 -3
  96. package/src/nodes/accessors/Camera.js +10 -16
  97. package/src/nodes/accessors/ClippingNode.js +7 -3
  98. package/src/nodes/accessors/CubeTextureNode.js +6 -3
  99. package/src/nodes/accessors/InstanceNode.js +11 -11
  100. package/src/nodes/accessors/InstancedPointsMaterialNode.js +6 -3
  101. package/src/nodes/accessors/Lights.js +51 -0
  102. package/src/nodes/accessors/MaterialNode.js +8 -4
  103. package/src/nodes/accessors/MaterialReferenceNode.js +6 -3
  104. package/src/nodes/accessors/ModelNode.js +42 -7
  105. package/src/nodes/accessors/ModelViewProjectionNode.js +9 -5
  106. package/src/nodes/accessors/MorphNode.js +7 -3
  107. package/src/nodes/accessors/Normal.js +32 -6
  108. package/src/nodes/accessors/Object3DNode.js +11 -27
  109. package/src/nodes/accessors/PointUVNode.js +7 -3
  110. package/src/nodes/accessors/ReferenceBaseNode.js +32 -4
  111. package/src/nodes/accessors/ReferenceNode.js +40 -3
  112. package/src/nodes/accessors/RendererReferenceNode.js +9 -3
  113. package/src/nodes/accessors/SceneNode.js +7 -3
  114. package/src/nodes/accessors/SkinningNode.js +7 -3
  115. package/src/nodes/accessors/StorageBufferNode.js +21 -3
  116. package/src/nodes/accessors/StorageTextureNode.js +7 -4
  117. package/src/nodes/accessors/Texture3DNode.js +7 -4
  118. package/src/nodes/accessors/TextureNode.js +19 -8
  119. package/src/nodes/accessors/TextureSizeNode.js +8 -5
  120. package/src/nodes/accessors/UniformArrayNode.js +12 -9
  121. package/src/nodes/accessors/UserDataNode.js +9 -6
  122. package/src/nodes/accessors/VelocityNode.js +74 -23
  123. package/src/nodes/accessors/VertexColorNode.js +6 -3
  124. package/src/nodes/code/CodeNode.js +7 -3
  125. package/src/nodes/code/ExpressionNode.js +8 -4
  126. package/src/nodes/code/FunctionCallNode.js +6 -3
  127. package/src/nodes/code/FunctionNode.js +6 -3
  128. package/src/nodes/code/ScriptableNode.js +11 -6
  129. package/src/nodes/code/ScriptableValueNode.js +7 -3
  130. package/src/nodes/core/AssignNode.js +9 -6
  131. package/src/nodes/core/AttributeNode.js +7 -3
  132. package/src/nodes/core/BypassNode.js +8 -4
  133. package/src/nodes/core/CacheNode.js +8 -4
  134. package/src/nodes/core/ConstNode.js +6 -3
  135. package/src/nodes/core/ContextNode.js +7 -3
  136. package/src/nodes/core/IndexNode.js +25 -3
  137. package/src/nodes/core/InputNode.js +7 -3
  138. package/src/nodes/core/MRTNode.js +6 -3
  139. package/src/nodes/core/Node.js +10 -51
  140. package/src/nodes/core/NodeBuilder.js +71 -5
  141. package/src/nodes/core/NodeUtils.js +48 -6
  142. package/src/nodes/core/OutputStructNode.js +8 -4
  143. package/src/nodes/core/ParameterNode.js +6 -3
  144. package/src/nodes/core/PropertyNode.js +7 -3
  145. package/src/nodes/core/StackNode.js +7 -3
  146. package/src/nodes/core/StructTypeNode.js +7 -3
  147. package/src/nodes/core/TempNode.js +8 -4
  148. package/src/nodes/core/UniformGroupNode.js +10 -6
  149. package/src/nodes/core/UniformNode.js +6 -3
  150. package/src/nodes/core/VarNode.js +8 -4
  151. package/src/nodes/core/VaryingNode.js +7 -3
  152. package/src/nodes/display/AfterImageNode.js +6 -0
  153. package/src/nodes/display/AnaglyphPassNode.js +6 -0
  154. package/src/nodes/display/AnamorphicNode.js +6 -0
  155. package/src/nodes/display/BloomNode.js +6 -0
  156. package/src/nodes/display/BumpMapNode.js +6 -0
  157. package/src/nodes/display/ColorSpaceFunctions.js +4 -4
  158. package/src/nodes/display/ColorSpaceNode.js +43 -14
  159. package/src/nodes/display/DenoiseNode.js +6 -3
  160. package/src/nodes/display/DepthOfFieldNode.js +6 -3
  161. package/src/nodes/display/DotScreenNode.js +8 -5
  162. package/src/nodes/display/FXAANode.js +6 -3
  163. package/src/nodes/display/FilmNode.js +6 -3
  164. package/src/nodes/display/FrontFacingNode.js +7 -3
  165. package/src/nodes/display/GTAONode.js +6 -3
  166. package/src/nodes/display/GaussianBlurNode.js +6 -3
  167. package/src/nodes/display/Lut3DNode.js +6 -3
  168. package/src/nodes/display/NormalMapNode.js +8 -6
  169. package/src/nodes/display/ParallaxBarrierPassNode.js +8 -5
  170. package/src/nodes/display/PassNode.js +18 -7
  171. package/src/nodes/display/PixelationPassNode.js +12 -5
  172. package/src/nodes/display/PosterizeNode.js +6 -3
  173. package/src/nodes/display/RGBShiftNode.js +6 -3
  174. package/src/nodes/display/RenderOutputNode.js +12 -8
  175. package/src/nodes/display/SSAAPassNode.js +6 -3
  176. package/src/nodes/display/ScreenNode.js +181 -0
  177. package/src/nodes/display/SobelOperatorNode.js +6 -3
  178. package/src/nodes/display/StereoCompositePassNode.js +6 -3
  179. package/src/nodes/display/StereoPassNode.js +6 -3
  180. package/src/nodes/display/ToneMappingFunctions.js +12 -12
  181. package/src/nodes/display/ToneMappingNode.js +8 -7
  182. package/src/nodes/display/ToonOutlinePassNode.js +111 -0
  183. package/src/nodes/display/TransitionNode.js +6 -3
  184. package/src/nodes/display/ViewportDepthNode.js +7 -3
  185. package/src/nodes/display/ViewportDepthTextureNode.js +8 -5
  186. package/src/nodes/display/ViewportSharedTextureNode.js +8 -5
  187. package/src/nodes/display/ViewportTextureNode.js +8 -5
  188. package/src/nodes/fog/FogExp2Node.js +6 -3
  189. package/src/nodes/fog/FogNode.js +7 -3
  190. package/src/nodes/fog/FogRangeNode.js +6 -3
  191. package/src/nodes/functions/PhysicalLightingModel.js +2 -2
  192. package/src/nodes/functions/material/getShIrradianceAt.js +28 -0
  193. package/src/nodes/geometry/RangeNode.js +7 -3
  194. package/src/nodes/gpgpu/AtomicFunctionNode.js +99 -0
  195. package/src/nodes/gpgpu/BarrierNode.js +40 -0
  196. package/src/nodes/gpgpu/ComputeBuiltinNode.js +98 -0
  197. package/src/nodes/gpgpu/ComputeNode.js +8 -4
  198. package/src/nodes/gpgpu/WorkgroupInfoNode.js +100 -0
  199. package/src/nodes/lighting/AONode.js +6 -3
  200. package/src/nodes/lighting/AmbientLightNode.js +6 -3
  201. package/src/nodes/lighting/AnalyticLightNode.js +198 -30
  202. package/src/nodes/lighting/BasicEnvironmentNode.js +6 -3
  203. package/src/nodes/lighting/BasicLightMapNode.js +6 -3
  204. package/src/nodes/lighting/DirectionalLightNode.js +7 -4
  205. package/src/nodes/lighting/EnvironmentNode.js +6 -3
  206. package/src/nodes/lighting/HemisphereLightNode.js +10 -6
  207. package/src/nodes/lighting/IESSpotLightNode.js +6 -3
  208. package/src/nodes/lighting/IrradianceNode.js +6 -3
  209. package/src/nodes/lighting/LightProbeNode.js +8 -31
  210. package/src/nodes/lighting/LightingContextNode.js +6 -3
  211. package/src/nodes/lighting/LightingNode.js +7 -3
  212. package/src/nodes/lighting/LightsNode.js +24 -5
  213. package/src/nodes/lighting/PointLightNode.js +11 -7
  214. package/src/nodes/lighting/RectAreaLightNode.js +11 -7
  215. package/src/nodes/lighting/SpotLightNode.js +13 -10
  216. package/src/nodes/math/ConditionalNode.js +23 -6
  217. package/src/nodes/math/MathNode.js +6 -3
  218. package/src/nodes/math/OperatorNode.js +6 -3
  219. package/src/nodes/pmrem/PMREMNode.js +6 -3
  220. package/src/nodes/utils/ArrayElementNode.js +8 -4
  221. package/src/nodes/utils/ConvertNode.js +7 -3
  222. package/src/nodes/utils/CubeMapNode.js +6 -3
  223. package/src/nodes/utils/EquirectUVNode.js +6 -3
  224. package/src/nodes/utils/FlipNode.js +7 -4
  225. package/src/nodes/utils/FunctionOverloadingNode.js +7 -3
  226. package/src/nodes/utils/JoinNode.js +6 -3
  227. package/src/nodes/utils/LoopNode.js +7 -3
  228. package/src/nodes/utils/MatcapUVNode.js +6 -3
  229. package/src/nodes/utils/MaxMipLevelNode.js +6 -3
  230. package/src/nodes/utils/OscNode.js +7 -3
  231. package/src/nodes/utils/RTTNode.js +6 -3
  232. package/src/nodes/utils/ReflectorNode.js +8 -5
  233. package/src/nodes/utils/RemapNode.js +7 -3
  234. package/src/nodes/utils/RotateNode.js +6 -3
  235. package/src/nodes/utils/SetNode.js +7 -4
  236. package/src/nodes/utils/SplitNode.js +7 -3
  237. package/src/nodes/utils/SpriteSheetUVNode.js +7 -3
  238. package/src/nodes/utils/StorageArrayElementNode.js +9 -8
  239. package/src/nodes/utils/TimerNode.js +6 -3
  240. package/src/nodes/utils/TriplanarTexturesNode.js +7 -3
  241. package/src/nodes/utils/ViewportUtils.js +2 -2
  242. package/src/objects/BatchedMesh.js +76 -10
  243. package/src/objects/LOD.js +21 -0
  244. package/src/objects/Line.js +1 -0
  245. package/src/objects/Mesh.js +7 -23
  246. package/src/objects/Points.js +2 -0
  247. package/src/renderers/WebGLRenderer.js +65 -50
  248. package/src/renderers/common/BundleGroup.js +26 -0
  249. package/src/renderers/common/ClippingContext.js +4 -3
  250. package/src/renderers/common/RenderContext.js +4 -5
  251. package/src/renderers/common/RenderObject.js +116 -5
  252. package/src/renderers/common/RenderObjects.js +8 -1
  253. package/src/renderers/common/Renderer.js +57 -49
  254. package/src/renderers/common/extras/PMREMGenerator.js +7 -9
  255. package/src/renderers/common/nodes/NodeBuilderState.js +3 -3
  256. package/src/renderers/common/nodes/Nodes.js +33 -14
  257. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +2 -4
  258. package/src/renderers/webgl/WebGLAttributes.js +45 -14
  259. package/src/renderers/webgl/WebGLCapabilities.js +9 -0
  260. package/src/renderers/webgl/WebGLProgram.js +2 -0
  261. package/src/renderers/webgl/WebGLPrograms.js +21 -17
  262. package/src/renderers/webgl/WebGLState.js +21 -0
  263. package/src/renderers/webgl/WebGLTextures.js +22 -0
  264. package/src/renderers/webgl-fallback/WebGLBackend.js +50 -45
  265. package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +4 -4
  266. package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +6 -0
  267. package/src/renderers/webgl-fallback/utils/WebGLState.js +1 -4
  268. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +61 -16
  269. package/src/renderers/webgpu/WebGPUBackend.js +33 -25
  270. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +42 -0
  271. package/src/renderers/webgpu/WebGPURenderer.js +5 -2
  272. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +59 -0
  273. package/src/renderers/{common → webgpu}/nodes/StandardNodeLibrary.js +11 -11
  274. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +91 -11
  275. package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -16
  276. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +1 -1
  277. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +7 -5
  278. package/src/renderers/webgpu/utils/WebGPUUtils.js +1 -1
  279. package/src/utils.js +33 -1
  280. package/examples/jsm/geometries/SDFGeometryGenerator.js +0 -144
  281. package/examples/jsm/loaders/TiltLoader.js +0 -520
  282. package/examples/jsm/utils/GPUStatsPanel.js +0 -95
  283. package/examples/jsm/utils/PackedPhongMaterial.js +0 -178
  284. package/src/nodes/display/ViewportNode.js +0 -138
  285. package/src/nodes/lighting/LightNode.js +0 -57
  286. package/src/renderers/common/StandardRenderer.js +0 -18
  287. package/src/renderers/webvr/WebVRManager.js +0 -495
  288. package/src/renderers/webvr/WebVRUtils.js +0 -66
package/src/utils.js CHANGED
@@ -117,4 +117,36 @@ function probeAsync( gl, sync, interval ) {
117
117
 
118
118
  }
119
119
 
120
- export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce, probeAsync };
120
+ function toNormalizedProjectionMatrix( projectionMatrix ) {
121
+
122
+ const m = projectionMatrix.elements;
123
+
124
+ // Convert [-1, 1] to [0, 1] projection matrix
125
+ m[ 2 ] = 0.5 * m[ 2 ] + 0.5 * m[ 3 ];
126
+ m[ 6 ] = 0.5 * m[ 6 ] + 0.5 * m[ 7 ];
127
+ m[ 10 ] = 0.5 * m[ 10 ] + 0.5 * m[ 11 ];
128
+ m[ 14 ] = 0.5 * m[ 14 ] + 0.5 * m[ 15 ];
129
+
130
+ }
131
+
132
+ function toReversedProjectionMatrix( projectionMatrix ) {
133
+
134
+ const m = projectionMatrix.elements;
135
+ const isPerspectiveMatrix = m[ 11 ] === - 1;
136
+
137
+ // Reverse [0, 1] projection matrix
138
+ if ( isPerspectiveMatrix ) {
139
+
140
+ m[ 10 ] = - m[ 10 ] - 1;
141
+ m[ 14 ] = - m[ 14 ];
142
+
143
+ } else {
144
+
145
+ m[ 10 ] = - m[ 10 ];
146
+ m[ 14 ] = - m[ 14 ] + 1;
147
+
148
+ }
149
+
150
+ }
151
+
152
+ export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, createCanvasElement, warnOnce, probeAsync, toNormalizedProjectionMatrix, toReversedProjectionMatrix };
@@ -1,144 +0,0 @@
1
- /**
2
- * @author santiago / @glitch_life
3
- * wrapper of https://www.npmjs.com/package/isosurface by https://github.com/mikolalysenko
4
- *
5
- * Returns BufferGeometry from SDF
6
- */
7
-
8
- import {
9
- BufferAttribute,
10
- BufferGeometry,
11
- FloatType,
12
- Mesh,
13
- OrthographicCamera,
14
- PlaneGeometry,
15
- Scene,
16
- ShaderMaterial,
17
- Vector2,
18
- WebGLRenderTarget
19
- } from 'three';
20
-
21
- import { surfaceNet } from './../libs/surfaceNet.js';
22
-
23
- class SDFGeometryGenerator {
24
-
25
- constructor( renderer ) {
26
-
27
- this.renderer = renderer;
28
-
29
- }
30
-
31
- generate( res = 64, distFunc = 'float dist( vec3 p ){ return length(p) - 0.5; }', bounds = 1 ) {
32
-
33
- let w, h;
34
- if ( res == 8 ) [ w, h ] = [ 32, 16 ];
35
- else if ( res == 16 ) [ w, h ] = [ 64, 64 ];
36
- else if ( res == 32 ) [ w, h ] = [ 256, 128 ];
37
- else if ( res == 64 ) [ w, h ] = [ 512, 512 ];
38
- else if ( res == 128 ) [ w, h ] = [ 2048, 1024 ];
39
- else if ( res == 256 ) [ w, h ] = [ 4096, 4096 ];
40
- else if ( res == 512 ) [ w, h ] = [ 16384, 8096 ];
41
- else if ( res == 1024 ) [ w, h ] = [ 32768, 32768 ];
42
- else throw new Error( 'THREE.SDFGeometryGenerator: Resolution must be in range 8 < res < 1024 and must be ^2' );
43
-
44
- const maxTexSize = this.renderer.capabilities.maxTextureSize;
45
-
46
- if ( w > maxTexSize || h > maxTexSize ) throw new Error( 'THREE.SDFGeometryGenerator: Your device does not support this resolution ( ' + res + ' ), decrease [res] param.' );
47
-
48
- const [ tilesX, tilesY ] = [ ( w / res ), ( h / res ) ];
49
-
50
- const sdfCompute = `
51
- varying vec2 vUv;
52
- uniform float tileNum;
53
- uniform float bounds;
54
- [#dist#]
55
- void main() { gl_FragColor=vec4( ( dist( vec3( vUv, tileNum ) * 2.0 * bounds - vec3( bounds ) ) < 0.00001 ) ? 1.0 : 0.0 ); }
56
- `;
57
-
58
- const sdfRT = this.computeSDF( w, h, tilesX, tilesY, bounds, sdfCompute.replace( '[#dist#]', distFunc ) );
59
-
60
- const read = new Float32Array( w * h * 4 );
61
- this.renderer.readRenderTargetPixels( sdfRT, 0, 0, w, h, read );
62
- sdfRT.dispose();
63
-
64
- //
65
-
66
- const mesh = surfaceNet( [ res, res, res ], ( x, y, z ) => {
67
-
68
- x = ( x + bounds ) * ( res / ( bounds * 2 ) );
69
- y = ( y + bounds ) * ( res / ( bounds * 2 ) );
70
- z = ( z + bounds ) * ( res / ( bounds * 2 ) );
71
- let p = ( x + ( z % tilesX ) * res ) + y * w + ( Math.floor( z / tilesX ) * res * w );
72
- p *= 4;
73
- return ( read[ p + 3 ] > 0 ) ? - 0.000000001 : 1;
74
-
75
- }, [[ - bounds, - bounds, - bounds ], [ bounds, bounds, bounds ]] );
76
-
77
- const ps = [], ids = [];
78
- const geometry = new BufferGeometry();
79
- mesh.positions.forEach( p => {
80
-
81
- ps.push( p[ 0 ], p[ 1 ], p[ 2 ] );
82
-
83
- } );
84
- mesh.cells.forEach( p => ids.push( p[ 0 ], p[ 1 ], p[ 2 ] ) );
85
- geometry.setAttribute( 'position', new BufferAttribute( new Float32Array( ps ), 3 ) );
86
- geometry.setIndex( ids );
87
-
88
- return geometry;
89
-
90
- }
91
-
92
- computeSDF( width, height, tilesX, tilesY, bounds, shader ) {
93
-
94
- const rt = new WebGLRenderTarget( width, height, { type: FloatType } );
95
- const scn = new Scene();
96
- const cam = new OrthographicCamera();
97
- const tiles = tilesX * tilesY;
98
- let currentTile = 0;
99
-
100
- Object.assign( cam, { left: width / - 2, right: width / 2, top: height / 2, bottom: height / - 2 } ).updateProjectionMatrix();
101
- cam.position.z = 2;
102
-
103
- const tileSize = width / tilesX;
104
- const geometry = new PlaneGeometry( tileSize, tileSize );
105
-
106
- while ( currentTile ++ < tiles ) {
107
-
108
- const c = currentTile - 1;
109
- const [ px, py ] = [ ( tileSize ) / 2 + ( c % tilesX ) * ( tileSize ) - width / 2, ( tileSize ) / 2 + Math.floor( c / tilesX ) * ( tileSize ) - height / 2 ];
110
- const compPlane = new Mesh( geometry, new ShaderMaterial( {
111
- uniforms: {
112
- res: { value: new Vector2( width, height ) },
113
- tileNum: { value: c / ( tilesX * tilesY - 1 ) },
114
- bounds: { value: bounds }
115
- },
116
- vertexShader: 'varying vec2 vUv;void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}',
117
- fragmentShader: shader
118
- } ) );
119
- compPlane.position.set( px, py, 0 );
120
- scn.add( compPlane );
121
-
122
- }
123
-
124
- this.renderer.setRenderTarget( rt );
125
- this.renderer.render( scn, cam );
126
- this.renderer.setRenderTarget( null );
127
-
128
- //
129
-
130
- geometry.dispose();
131
-
132
- scn.traverse( function ( object ) {
133
-
134
- if ( object.material !== undefined ) object.material.dispose();
135
-
136
- } );
137
-
138
- return rt;
139
-
140
- }
141
-
142
- }
143
-
144
- export { SDFGeometryGenerator };
@@ -1,520 +0,0 @@
1
- import {
2
- BufferAttribute,
3
- BufferGeometry,
4
- Color,
5
- DoubleSide,
6
- FileLoader,
7
- Group,
8
- Loader,
9
- Mesh,
10
- MeshBasicMaterial,
11
- RawShaderMaterial,
12
- TextureLoader,
13
- Quaternion,
14
- Vector3
15
- } from 'three';
16
- import * as fflate from '../libs/fflate.module.js';
17
-
18
- class TiltLoader extends Loader {
19
-
20
- load( url, onLoad, onProgress, onError ) {
21
-
22
- const scope = this;
23
-
24
- const loader = new FileLoader( this.manager );
25
- loader.setPath( this.path );
26
- loader.setResponseType( 'arraybuffer' );
27
- loader.setWithCredentials( this.withCredentials );
28
-
29
- loader.load( url, function ( buffer ) {
30
-
31
- try {
32
-
33
- onLoad( scope.parse( buffer ) );
34
-
35
- } catch ( e ) {
36
-
37
- if ( onError ) {
38
-
39
- onError( e );
40
-
41
- } else {
42
-
43
- console.error( e );
44
-
45
- }
46
-
47
- scope.manager.itemError( url );
48
-
49
- }
50
-
51
- }, onProgress, onError );
52
-
53
- }
54
-
55
- parse( buffer ) {
56
-
57
- const group = new Group();
58
- // https://docs.google.com/document/d/11ZsHozYn9FnWG7y3s3WAyKIACfbfwb4PbaS8cZ_xjvo/edit#
59
-
60
- const zip = fflate.unzipSync( new Uint8Array( buffer.slice( 16 ) ) );
61
-
62
- /*
63
- const thumbnail = zip[ 'thumbnail.png' ].buffer;
64
- const img = document.createElement( 'img' );
65
- img.src = URL.createObjectURL( new Blob( [ thumbnail ] ) );
66
- document.body.appendChild( img );
67
- */
68
-
69
- const metadata = JSON.parse( fflate.strFromU8( zip[ 'metadata.json' ] ) );
70
-
71
- /*
72
- const blob = new Blob( [ zip[ 'data.sketch' ].buffer ], { type: 'application/octet-stream' } );
73
- window.open( URL.createObjectURL( blob ) );
74
- */
75
-
76
- const data = new DataView( zip[ 'data.sketch' ].buffer );
77
-
78
- const num_strokes = data.getInt32( 16, true );
79
-
80
- const brushes = {};
81
-
82
- let offset = 20;
83
-
84
- for ( let i = 0; i < num_strokes; i ++ ) {
85
-
86
- const brush_index = data.getInt32( offset, true );
87
-
88
- const brush_color = [
89
- data.getFloat32( offset + 4, true ),
90
- data.getFloat32( offset + 8, true ),
91
- data.getFloat32( offset + 12, true ),
92
- data.getFloat32( offset + 16, true )
93
- ];
94
- const brush_size = data.getFloat32( offset + 20, true );
95
- const stroke_mask = data.getUint32( offset + 24, true );
96
- const controlpoint_mask = data.getUint32( offset + 28, true );
97
-
98
- let offset_stroke_mask = 0;
99
- let offset_controlpoint_mask = 0;
100
-
101
- for ( let j = 0; j < 4; j ++ ) {
102
-
103
- // TOFIX: I don't understand these masks yet
104
-
105
- const byte = 1 << j;
106
- if ( ( stroke_mask & byte ) > 0 ) offset_stroke_mask += 4;
107
- if ( ( controlpoint_mask & byte ) > 0 ) offset_controlpoint_mask += 4;
108
-
109
- }
110
-
111
- // console.log( { brush_index, brush_color, brush_size, stroke_mask, controlpoint_mask } );
112
- // console.log( offset_stroke_mask, offset_controlpoint_mask );
113
-
114
- offset = offset + 28 + offset_stroke_mask + 4; // TOFIX: This is wrong
115
-
116
- const num_control_points = data.getInt32( offset, true );
117
-
118
- // console.log( { num_control_points } );
119
-
120
- const positions = new Float32Array( num_control_points * 3 );
121
- const quaternions = new Float32Array( num_control_points * 4 );
122
-
123
- offset = offset + 4;
124
-
125
- for ( let j = 0, k = 0; j < positions.length; j += 3, k += 4 ) {
126
-
127
- positions[ j + 0 ] = data.getFloat32( offset + 0, true );
128
- positions[ j + 1 ] = data.getFloat32( offset + 4, true );
129
- positions[ j + 2 ] = data.getFloat32( offset + 8, true );
130
-
131
- quaternions[ k + 0 ] = data.getFloat32( offset + 12, true );
132
- quaternions[ k + 1 ] = data.getFloat32( offset + 16, true );
133
- quaternions[ k + 2 ] = data.getFloat32( offset + 20, true );
134
- quaternions[ k + 3 ] = data.getFloat32( offset + 24, true );
135
-
136
- offset = offset + 28 + offset_controlpoint_mask; // TOFIX: This is wrong
137
-
138
- }
139
-
140
- if ( brush_index in brushes === false ) {
141
-
142
- brushes[ brush_index ] = [];
143
-
144
- }
145
-
146
- brushes[ brush_index ].push( [ positions, quaternions, brush_size, brush_color ] );
147
-
148
- }
149
-
150
- for ( const brush_index in brushes ) {
151
-
152
- const geometry = new StrokeGeometry( brushes[ brush_index ] );
153
- const material = getMaterial( metadata.BrushIndex[ brush_index ] );
154
-
155
- group.add( new Mesh( geometry, material ) );
156
-
157
- }
158
-
159
- return group;
160
-
161
- }
162
-
163
- }
164
-
165
- class StrokeGeometry extends BufferGeometry {
166
-
167
- constructor( strokes ) {
168
-
169
- super();
170
-
171
- const vertices = [];
172
- const colors = [];
173
- const uvs = [];
174
-
175
- const position = new Vector3();
176
- const prevPosition = new Vector3();
177
-
178
- const quaternion = new Quaternion();
179
- const prevQuaternion = new Quaternion();
180
-
181
- const vector1 = new Vector3();
182
- const vector2 = new Vector3();
183
- const vector3 = new Vector3();
184
- const vector4 = new Vector3();
185
-
186
- const color = new Color();
187
-
188
- // size = size / 2;
189
-
190
- for ( const k in strokes ) {
191
-
192
- const stroke = strokes[ k ];
193
- const positions = stroke[ 0 ];
194
- const quaternions = stroke[ 1 ];
195
- const size = stroke[ 2 ];
196
- const rgba = stroke[ 3 ];
197
- const alpha = stroke[ 3 ][ 3 ];
198
-
199
- color.fromArray( rgba ).convertSRGBToLinear();
200
-
201
- prevPosition.fromArray( positions, 0 );
202
- prevQuaternion.fromArray( quaternions, 0 );
203
-
204
- for ( let i = 3, j = 4, l = positions.length; i < l; i += 3, j += 4 ) {
205
-
206
- position.fromArray( positions, i );
207
- quaternion.fromArray( quaternions, j );
208
-
209
- vector1.set( - size, 0, 0 );
210
- vector1.applyQuaternion( quaternion );
211
- vector1.add( position );
212
-
213
- vector2.set( size, 0, 0 );
214
- vector2.applyQuaternion( quaternion );
215
- vector2.add( position );
216
-
217
- vector3.set( size, 0, 0 );
218
- vector3.applyQuaternion( prevQuaternion );
219
- vector3.add( prevPosition );
220
-
221
- vector4.set( - size, 0, 0 );
222
- vector4.applyQuaternion( prevQuaternion );
223
- vector4.add( prevPosition );
224
-
225
- vertices.push( vector1.x, vector1.y, - vector1.z );
226
- vertices.push( vector2.x, vector2.y, - vector2.z );
227
- vertices.push( vector4.x, vector4.y, - vector4.z );
228
-
229
- vertices.push( vector2.x, vector2.y, - vector2.z );
230
- vertices.push( vector3.x, vector3.y, - vector3.z );
231
- vertices.push( vector4.x, vector4.y, - vector4.z );
232
-
233
- prevPosition.copy( position );
234
- prevQuaternion.copy( quaternion );
235
-
236
- colors.push( ...color, alpha );
237
- colors.push( ...color, alpha );
238
- colors.push( ...color, alpha );
239
-
240
- colors.push( ...color, alpha );
241
- colors.push( ...color, alpha );
242
- colors.push( ...color, alpha );
243
-
244
- const p1 = i / l;
245
- const p2 = ( i - 3 ) / l;
246
-
247
- uvs.push( p1, 0 );
248
- uvs.push( p1, 1 );
249
- uvs.push( p2, 0 );
250
-
251
- uvs.push( p1, 1 );
252
- uvs.push( p2, 1 );
253
- uvs.push( p2, 0 );
254
-
255
- }
256
-
257
- }
258
-
259
- this.setAttribute( 'position', new BufferAttribute( new Float32Array( vertices ), 3 ) );
260
- this.setAttribute( 'color', new BufferAttribute( new Float32Array( colors ), 4 ) );
261
- this.setAttribute( 'uv', new BufferAttribute( new Float32Array( uvs ), 2 ) );
262
-
263
- }
264
-
265
- }
266
-
267
- const BRUSH_LIST_ARRAY = {
268
- '89d104cd-d012-426b-b5b3-bbaee63ac43c': 'Bubbles',
269
- '700f3aa8-9a7c-2384-8b8a-ea028905dd8c': 'CelVinyl',
270
- '0f0ff7b2-a677-45eb-a7d6-0cd7206f4816': 'ChromaticWave',
271
- '1161af82-50cf-47db-9706-0c3576d43c43': 'CoarseBristles',
272
- '79168f10-6961-464a-8be1-57ed364c5600': 'CoarseBristlesSingleSided',
273
- '1caa6d7d-f015-3f54-3a4b-8b5354d39f81': 'Comet',
274
- 'c8313697-2563-47fc-832e-290f4c04b901': 'DiamondHull',
275
- '4391aaaa-df73-4396-9e33-31e4e4930b27': 'Disco',
276
- 'd1d991f2-e7a0-4cf1-b328-f57e915e6260': 'DotMarker',
277
- '6a1cf9f9-032c-45ec-9b1d-a6680bee30f7': 'Dots',
278
- '0d3889f3-3ede-470c-8af4-f44813306126': 'DoubleTaperedFlat',
279
- '0d3889f3-3ede-470c-8af4-de4813306126': 'DoubleTaperedMarker',
280
- 'd0262945-853c-4481-9cbd-88586bed93cb': 'DuctTape',
281
- '3ca16e2f-bdcd-4da2-8631-dcef342f40f1': 'DuctTapeSingleSided',
282
- 'f6e85de3-6dcc-4e7f-87fd-cee8c3d25d51': 'Electricity',
283
- '02ffb866-7fb2-4d15-b761-1012cefb1360': 'Embers',
284
- 'cb92b597-94ca-4255-b017-0e3f42f12f9e': 'Fire',
285
- '2d35bcf0-e4d8-452c-97b1-3311be063130': 'Flat',
286
- '55303bc4-c749-4a72-98d9-d23e68e76e18': 'FlatDeprecated',
287
- '280c0a7a-aad8-416c-a7d2-df63d129ca70': 'FlatSingleSided',
288
- 'cf019139-d41c-4eb0-a1d0-5cf54b0a42f3': 'Highlighter',
289
- '6a1cf9f9-032c-45ec-9b6e-a6680bee32e9': 'HyperGrid',
290
- 'dce872c2-7b49-4684-b59b-c45387949c5c': 'Hypercolor',
291
- 'e8ef32b1-baa8-460a-9c2c-9cf8506794f5': 'HypercolorSingleSided',
292
- '2f212815-f4d3-c1a4-681a-feeaf9c6dc37': 'Icing',
293
- 'f5c336cf-5108-4b40-ade9-c687504385ab': 'Ink',
294
- 'c0012095-3ffd-4040-8ee1-fc180d346eaa': 'InkSingleSided',
295
- '4a76a27a-44d8-4bfe-9a8c-713749a499b0': 'Leaves',
296
- 'ea19de07-d0c0-4484-9198-18489a3c1487': 'LeavesSingleSided',
297
- '2241cd32-8ba2-48a5-9ee7-2caef7e9ed62': 'Light',
298
- '4391aaaa-df81-4396-9e33-31e4e4930b27': 'LightWire',
299
- 'd381e0f5-3def-4a0d-8853-31e9200bcbda': 'Lofted',
300
- '429ed64a-4e97-4466-84d3-145a861ef684': 'Marker',
301
- '79348357-432d-4746-8e29-0e25c112e3aa': 'MatteHull',
302
- 'b2ffef01-eaaa-4ab5-aa64-95a2c4f5dbc6': 'NeonPulse',
303
- 'f72ec0e7-a844-4e38-82e3-140c44772699': 'OilPaint',
304
- 'c515dad7-4393-4681-81ad-162ef052241b': 'OilPaintSingleSided',
305
- 'f1114e2e-eb8d-4fde-915a-6e653b54e9f5': 'Paper',
306
- '759f1ebd-20cd-4720-8d41-234e0da63716': 'PaperSingleSided',
307
- 'e0abbc80-0f80-e854-4970-8924a0863dcc': 'Petal',
308
- 'c33714d1-b2f9-412e-bd50-1884c9d46336': 'Plasma',
309
- 'ad1ad437-76e2-450d-a23a-e17f8310b960': 'Rainbow',
310
- 'faaa4d44-fcfb-4177-96be-753ac0421ba3': 'ShinyHull',
311
- '70d79cca-b159-4f35-990c-f02193947fe8': 'Smoke',
312
- 'd902ed8b-d0d1-476c-a8de-878a79e3a34c': 'Snow',
313
- 'accb32f5-4509-454f-93f8-1df3fd31df1b': 'SoftHighlighter',
314
- 'cf7f0059-7aeb-53a4-2b67-c83d863a9ffa': 'Spikes',
315
- '8dc4a70c-d558-4efd-a5ed-d4e860f40dc3': 'Splatter',
316
- '7a1c8107-50c5-4b70-9a39-421576d6617e': 'SplatterSingleSided',
317
- '0eb4db27-3f82-408d-b5a1-19ebd7d5b711': 'Stars',
318
- '44bb800a-fbc3-4592-8426-94ecb05ddec3': 'Streamers',
319
- '0077f88c-d93a-42f3-b59b-b31c50cdb414': 'Taffy',
320
- 'b468c1fb-f254-41ed-8ec9-57030bc5660c': 'TaperedFlat',
321
- 'c8ccb53d-ae13-45ef-8afb-b730d81394eb': 'TaperedFlatSingleSided',
322
- 'd90c6ad8-af0f-4b54-b422-e0f92abe1b3c': 'TaperedMarker',
323
- '1a26b8c0-8a07-4f8a-9fac-d2ef36e0cad0': 'TaperedMarker_Flat',
324
- '75b32cf0-fdd6-4d89-a64b-e2a00b247b0f': 'ThickPaint',
325
- 'fdf0326a-c0d1-4fed-b101-9db0ff6d071f': 'ThickPaintSingleSided',
326
- '4391385a-df73-4396-9e33-31e4e4930b27': 'Toon',
327
- 'a8fea537-da7c-4d4b-817f-24f074725d6d': 'UnlitHull',
328
- 'd229d335-c334-495a-a801-660ac8a87360': 'VelvetInk',
329
- '10201aa3-ebc2-42d8-84b7-2e63f6eeb8ab': 'Waveform',
330
- 'b67c0e81-ce6d-40a8-aeb0-ef036b081aa3': 'WetPaint',
331
- 'dea67637-cd1a-27e4-c9b1-52f4bbcb84e5': 'WetPaintSingleSided',
332
- '5347acf0-a8e2-47b6-8346-30c70719d763': 'WigglyGraphite',
333
- 'e814fef1-97fd-7194-4a2f-50c2bb918be2': 'WigglyGraphiteSingleSided',
334
- '4391385a-cf83-4396-9e33-31e4e4930b27': 'Wire'
335
- };
336
-
337
- const common = {
338
-
339
- 'colors': {
340
-
341
- 'BloomColor': `
342
- vec3 BloomColor(vec3 color, float gain) {
343
- // Guarantee that there's at least a little bit of all 3 channels.
344
- // This makes fully-saturated strokes (which only have 2 non-zero
345
- // color channels) eventually clip to white rather than to a secondary.
346
- float cmin = length(color.rgb) * .05;
347
- color.rgb = max(color.rgb, vec3(cmin, cmin, cmin));
348
- // If we try to remove this pow() from .a, it brightens up
349
- // pressure-sensitive strokes; looks better as-is.
350
- color = pow(color, vec3(2.2));
351
- color.rgb *= 2. * exp(gain * 10.);
352
- return color;
353
- }
354
- `,
355
-
356
- 'LinearToSrgb': `
357
- vec3 LinearToSrgb(vec3 color) {
358
- // Approximation http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html
359
- vec3 linearColor = color.rgb;
360
- vec3 S1 = sqrt(linearColor);
361
- vec3 S2 = sqrt(S1);
362
- vec3 S3 = sqrt(S2);
363
- color.rgb = 0.662002687 * S1 + 0.684122060 * S2 - 0.323583601 * S3 - 0.0225411470 * linearColor;
364
- return color;
365
- }
366
- `,
367
-
368
- 'hsv': `
369
- // uniform sampler2D lookupTex;
370
- vec4 lookup(vec4 textureColor) {
371
- return textureColor;
372
- }
373
-
374
- vec3 lookup(vec3 textureColor) {
375
- return textureColor;
376
- }
377
-
378
- vec3 hsv2rgb( vec3 hsv ) {
379
- vec3 rgb = clamp( abs(mod(hsv.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
380
- return hsv.z * mix( vec3(1.0), rgb, hsv.y);
381
- }
382
-
383
- vec3 rgb2hsv( vec3 rgb ) {
384
- vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
385
- vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));
386
- vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
387
-
388
- float d = q.x - min(q.w, q.y);
389
- float e = 1.0e-10;
390
-
391
- return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
392
- }
393
- `,
394
-
395
- 'SrgbToLinear': `
396
- vec3 SrgbToLinear(vec3 color) {
397
- // Approximation http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html
398
- vec3 sRGB = color.rgb;
399
- color.rgb = sRGB * (sRGB * (sRGB * 0.305306011 + 0.682171111) + 0.012522878);
400
- return color;
401
- }
402
- `
403
-
404
- }
405
-
406
- };
407
-
408
- let shaders = null;
409
-
410
- function getShaders() {
411
-
412
- if ( shaders === null ) {
413
-
414
- const loader = new TextureLoader().setPath( './textures/tiltbrush/' );
415
-
416
- shaders = {
417
- 'Light': {
418
- uniforms: {
419
- mainTex: { value: loader.load( 'Light.webp' ) },
420
- alphaTest: { value: 0.067 },
421
- emission_gain: { value: 0.45 },
422
- alpha: { value: 1 },
423
- },
424
- vertexShader: `
425
- precision highp float;
426
- precision highp int;
427
-
428
- attribute vec2 uv;
429
- attribute vec4 color;
430
- attribute vec3 position;
431
-
432
- uniform mat4 modelMatrix;
433
- uniform mat4 modelViewMatrix;
434
- uniform mat4 projectionMatrix;
435
- uniform mat4 viewMatrix;
436
- uniform mat3 normalMatrix;
437
- uniform vec3 cameraPosition;
438
-
439
- varying vec2 vUv;
440
- varying vec3 vColor;
441
-
442
- ${ common.colors.LinearToSrgb }
443
- ${ common.colors.hsv }
444
-
445
- void main() {
446
-
447
- vUv = uv;
448
-
449
- vColor = lookup(color.rgb);
450
-
451
- vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
452
-
453
- gl_Position = projectionMatrix * mvPosition;
454
-
455
- }
456
- `,
457
- fragmentShader: `
458
- precision highp float;
459
- precision highp int;
460
-
461
- uniform float emission_gain;
462
-
463
- uniform sampler2D mainTex;
464
- uniform float alphaTest;
465
-
466
- varying vec2 vUv;
467
- varying vec3 vColor;
468
-
469
- ${ common.colors.BloomColor }
470
- ${ common.colors.SrgbToLinear }
471
-
472
- void main(){
473
- vec4 col = texture2D(mainTex, vUv);
474
- vec3 color = vColor;
475
- color = BloomColor(color, emission_gain);
476
- color = color * col.rgb;
477
- color = color * col.a;
478
- color = SrgbToLinear(color);
479
- gl_FragColor = vec4(color, 1.0);
480
- }
481
- `,
482
- side: 2,
483
- transparent: true,
484
- depthFunc: 2,
485
- depthWrite: true,
486
- depthTest: false,
487
- blending: 5,
488
- blendDst: 201,
489
- blendDstAlpha: 201,
490
- blendEquation: 100,
491
- blendEquationAlpha: 100,
492
- blendSrc: 201,
493
- blendSrcAlpha: 201,
494
- }
495
-
496
- };
497
-
498
- }
499
-
500
- return shaders;
501
-
502
- }
503
-
504
- function getMaterial( GUID ) {
505
-
506
- const name = BRUSH_LIST_ARRAY[ GUID ];
507
-
508
- switch ( name ) {
509
-
510
- case 'Light':
511
- return new RawShaderMaterial( getShaders().Light );
512
-
513
- default:
514
- return new MeshBasicMaterial( { vertexColors: true, side: DoubleSide } );
515
-
516
- }
517
-
518
- }
519
-
520
- export { TiltLoader };