super-three 0.136.0 → 0.136.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.
- package/LICENSE +1 -1
- package/build/three.js +1634 -1608
- package/build/three.min.js +1 -1
- package/build/three.module.js +4630 -4534
- package/examples/js/animation/MMDPhysics.js +1 -1
- package/examples/js/cameras/CinematicCamera.js +2 -7
- package/examples/js/exporters/MMDExporter.js +1 -1
- package/examples/js/geometries/ConvexGeometry.js +1 -1
- package/examples/js/loaders/BasisTextureLoader.js +1 -0
- package/examples/js/loaders/EXRLoader.js +25 -19
- package/examples/js/loaders/GLTFLoader.js +2 -2
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -2
- package/examples/js/loaders/LDrawLoader.js +1131 -859
- package/examples/js/loaders/LUT3dlLoader.js +17 -10
- package/examples/js/loaders/LUTCubeLoader.js +3 -4
- package/examples/js/loaders/RGBELoader.js +6 -6
- package/examples/js/loaders/RGBMLoader.js +1 -1
- package/examples/js/loaders/SVGLoader.js +3 -1
- package/examples/js/loaders/VRMLLoader.js +9 -21
- package/examples/js/math/ConvexHull.js +7 -13
- package/examples/js/misc/Volume.js +2 -2
- package/examples/js/modifiers/CurveModifier.js +8 -7
- package/examples/js/modifiers/EdgeSplitModifier.js +1 -1
- package/examples/js/modifiers/SimplifyModifier.js +1 -1
- package/examples/js/objects/Reflector.js +1 -13
- package/examples/js/objects/ReflectorForSSRPass.js +0 -10
- package/examples/js/objects/Refractor.js +1 -13
- package/examples/js/objects/Water.js +1 -13
- package/examples/js/postprocessing/GlitchPass.js +4 -5
- package/examples/js/postprocessing/SMAAPass.js +2 -9
- package/examples/js/postprocessing/SSAOPass.js +9 -21
- package/examples/js/postprocessing/SavePass.js +1 -5
- package/examples/js/shaders/DigitalGlitch.js +3 -3
- package/examples/js/shaders/MMDToonShader.js +0 -1
- package/examples/js/shaders/SSAOShader.js +1 -1
- package/examples/jsm/animation/MMDPhysics.js +1 -1
- package/examples/jsm/cameras/CinematicCamera.js +2 -5
- package/examples/jsm/{WebGL.js → capabilities/WebGL.js} +2 -2
- package/examples/jsm/{renderers/webgpu → capabilities}/WebGPU.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +8 -24
- package/examples/jsm/exporters/MMDExporter.js +1 -1
- package/examples/jsm/geometries/ConvexGeometry.js +1 -1
- package/examples/jsm/libs/lil-gui.module.min.js +2 -2
- package/examples/jsm/loaders/BasisTextureLoader.js +7 -0
- package/examples/jsm/loaders/EXRLoader.js +22 -19
- package/examples/jsm/loaders/GLTFLoader.js +1 -3
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -4
- package/examples/jsm/loaders/LDrawLoader.js +1147 -885
- package/examples/jsm/loaders/LUT3dlLoader.js +17 -12
- package/examples/jsm/loaders/LUTCubeLoader.js +3 -5
- package/examples/jsm/loaders/RGBELoader.js +7 -8
- package/examples/jsm/loaders/RGBMLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +6 -1
- package/examples/jsm/loaders/VRMLLoader.js +9 -22
- package/examples/jsm/math/ConvexHull.js +7 -13
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +9 -8
- package/examples/jsm/modifiers/EdgeSplitModifier.js +1 -1
- package/examples/jsm/modifiers/SimplifyModifier.js +1 -1
- package/examples/jsm/node-editor/NodeEditor.js +21 -22
- package/examples/jsm/nodes/utils/ColorSpaceNode.js +4 -13
- package/examples/jsm/objects/Lensflare.js +4 -4
- package/examples/jsm/objects/Reflector.js +1 -16
- package/examples/jsm/objects/ReflectorForSSRPass.js +0 -12
- package/examples/jsm/objects/Refractor.js +1 -16
- package/examples/jsm/objects/Water.js +1 -16
- package/examples/jsm/postprocessing/GlitchPass.js +7 -6
- package/examples/jsm/postprocessing/SMAAPass.js +2 -11
- package/examples/jsm/postprocessing/SSAOPass.js +13 -25
- package/examples/jsm/postprocessing/SavePass.js +1 -3
- package/examples/jsm/renderers/nodes/Nodes.js +2 -0
- package/examples/jsm/renderers/nodes/ShaderNode.js +58 -31
- package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +9 -46
- package/examples/jsm/renderers/nodes/inputs/TextureNode.js +5 -10
- package/examples/jsm/renderers/nodes/math/MathNode.js +2 -1
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +1 -1
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +3 -5
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +1 -2
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +10 -4
- package/examples/jsm/shaders/DigitalGlitch.js +3 -3
- package/examples/jsm/shaders/MMDToonShader.js +0 -1
- package/examples/jsm/shaders/SSAOShader.js +1 -1
- package/examples/jsm/utils/LDrawUtils.js +195 -0
- package/examples/jsm/webxr/VRButton.js +24 -0
- package/examples/jsm/webxr/XREstimatedLight.js +2 -0
- package/package.json +4 -1
- package/src/animation/AnimationMixer.js +1 -0
- package/src/cameras/CubeCamera.js +2 -0
- package/src/constants.js +3 -16
- package/src/extras/ImageUtils.js +63 -0
- package/src/extras/PMREMGenerator.js +32 -82
- package/src/loaders/MaterialLoader.js +1 -1
- package/src/materials/Material.js +4 -4
- package/src/math/Color.js +1 -1
- package/src/math/Quaternion.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +0 -2
- package/src/renderers/WebGLRenderer.js +1 -67
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +10 -3
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +1 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +8 -7
- package/src/renderers/shaders/ShaderLib/background.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +1 -3
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib.js +2 -2
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -4
- package/src/renderers/webgl/WebGLCubeUVMaps.js +29 -16
- package/src/renderers/webgl/WebGLMorphtargets.js +12 -0
- package/src/renderers/webgl/WebGLProgram.js +4 -16
- package/src/renderers/webgl/WebGLPrograms.js +8 -47
- package/src/renderers/webgl/WebGLState.js +81 -0
- package/src/renderers/webgl/WebGLTextures.js +75 -22
- package/src/renderers/webgl/WebGLUtils.js +86 -28
- package/src/renderers/webxr/WebXRManager.js +3 -3
- package/src/textures/Texture.js +2 -1
- package/src/textures/VideoTexture.js +1 -3
- package/examples/js/WebGL.js +0 -90
- package/examples/js/utils/RoughnessMipmapper.js +0 -268
- package/examples/jsm/utils/RoughnessMipmapper.js +0 -288
|
@@ -62,7 +62,7 @@ const DigitalGlitch = {
|
|
|
62
62
|
float xs = floor(gl_FragCoord.x / 0.5);
|
|
63
63
|
float ys = floor(gl_FragCoord.y / 0.5);
|
|
64
64
|
//based on staffantans glitch shader for unity https://github.com/staffantan/unityglitch
|
|
65
|
-
|
|
65
|
+
float disp = texture2D(tDisp, p*seed*seed).r;
|
|
66
66
|
if(p.y<distortion_x+col_s && p.y>distortion_x-col_s*seed) {
|
|
67
67
|
if(seed_x>0.){
|
|
68
68
|
p.y = 1. - (p.y + distortion_y);
|
|
@@ -79,8 +79,8 @@ const DigitalGlitch = {
|
|
|
79
79
|
p.x = 1. - (p.x + distortion_x);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
p.x+=
|
|
83
|
-
p.y+=
|
|
82
|
+
p.x+=disp*seed_x*(seed/5.);
|
|
83
|
+
p.y+=disp*seed_y*(seed/5.);
|
|
84
84
|
//base from RGB shift shader
|
|
85
85
|
vec2 offset = amount * vec2( cos(angle), sin(angle));
|
|
86
86
|
vec4 cr = texture2D(tDiffuse, p + offset);
|
|
@@ -57,7 +57,6 @@ const mmd_toon_matcap_fragment = `
|
|
|
57
57
|
vec3 y = cross( viewDir, x );
|
|
58
58
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks
|
|
59
59
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
60
|
-
matcapColor = matcapTexelToLinear( matcapColor );
|
|
61
60
|
|
|
62
61
|
#ifdef MATCAP_BLENDING_MULTIPLY
|
|
63
62
|
|
|
@@ -134,7 +134,7 @@ const SSAOShader = {
|
|
|
134
134
|
vec3 viewNormal = getViewNormal( vUv );
|
|
135
135
|
|
|
136
136
|
vec2 noiseScale = vec2( resolution.x / 4.0, resolution.y / 4.0 );
|
|
137
|
-
vec3 random = texture2D( tNoise, vUv * noiseScale ).
|
|
137
|
+
vec3 random = vec3( texture2D( tNoise, vUv * noiseScale ).r );
|
|
138
138
|
|
|
139
139
|
// compute matrix used to reorient a kernel vector
|
|
140
140
|
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BufferAttribute,
|
|
3
|
+
BufferGeometry,
|
|
4
|
+
Group,
|
|
5
|
+
LineSegments,
|
|
6
|
+
Matrix3,
|
|
7
|
+
Mesh
|
|
8
|
+
} from 'three';
|
|
9
|
+
|
|
10
|
+
import { mergeBufferGeometries } from './BufferGeometryUtils.js';
|
|
11
|
+
|
|
12
|
+
class LDrawUtils {
|
|
13
|
+
|
|
14
|
+
static mergeObject( object ) {
|
|
15
|
+
|
|
16
|
+
// Merges geometries in object by materials and returns new object. Use on not indexed geometries.
|
|
17
|
+
// The object buffers reference the old object ones.
|
|
18
|
+
// Special treatment is done to the conditional lines generated by LDrawLoader.
|
|
19
|
+
|
|
20
|
+
function extractGroup( geometry, group, elementSize, isConditionalLine ) {
|
|
21
|
+
|
|
22
|
+
// Extracts a group from a geometry as a new geometry (with attribute buffers referencing original buffers)
|
|
23
|
+
|
|
24
|
+
const newGeometry = new BufferGeometry();
|
|
25
|
+
|
|
26
|
+
const originalPositions = geometry.getAttribute( 'position' ).array;
|
|
27
|
+
const originalNormals = elementSize === 3 ? geometry.getAttribute( 'normal' ).array : null;
|
|
28
|
+
|
|
29
|
+
const numVertsGroup = Math.min( group.count, Math.floor( originalPositions.length / 3 ) - group.start );
|
|
30
|
+
const vertStart = group.start * 3;
|
|
31
|
+
const vertEnd = ( group.start + numVertsGroup ) * 3;
|
|
32
|
+
|
|
33
|
+
const positions = originalPositions.subarray( vertStart, vertEnd );
|
|
34
|
+
const normals = originalNormals !== null ? originalNormals.subarray( vertStart, vertEnd ) : null;
|
|
35
|
+
|
|
36
|
+
newGeometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) );
|
|
37
|
+
if ( normals !== null ) newGeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ) );
|
|
38
|
+
|
|
39
|
+
if ( isConditionalLine ) {
|
|
40
|
+
|
|
41
|
+
const controlArray0 = geometry.getAttribute( 'control0' ).array.subarray( vertStart, vertEnd );
|
|
42
|
+
const controlArray1 = geometry.getAttribute( 'control1' ).array.subarray( vertStart, vertEnd );
|
|
43
|
+
const directionArray = geometry.getAttribute( 'direction' ).array.subarray( vertStart, vertEnd );
|
|
44
|
+
|
|
45
|
+
newGeometry.setAttribute( 'control0', new BufferAttribute( controlArray0, 3, false ) );
|
|
46
|
+
newGeometry.setAttribute( 'control1', new BufferAttribute( controlArray1, 3, false ) );
|
|
47
|
+
newGeometry.setAttribute( 'direction', new BufferAttribute( directionArray, 3, false ) );
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return newGeometry;
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function addGeometry( mat, geometry, geometries ) {
|
|
56
|
+
|
|
57
|
+
const geoms = geometries[ mat.uuid ];
|
|
58
|
+
if ( ! geoms ) {
|
|
59
|
+
|
|
60
|
+
geometries[ mat.uuid ] = {
|
|
61
|
+
mat: mat,
|
|
62
|
+
arr: [ geometry ]
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
else geoms.arr.push( geometry );
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function permuteAttribute( attribute, elemSize ) {
|
|
71
|
+
|
|
72
|
+
// Permutes first two vertices of each attribute element
|
|
73
|
+
|
|
74
|
+
if ( ! attribute ) return;
|
|
75
|
+
|
|
76
|
+
const verts = attribute.array;
|
|
77
|
+
const numVerts = Math.floor( verts.length / 3 );
|
|
78
|
+
let offset = 0;
|
|
79
|
+
for ( let i = 0; i < numVerts; i ++ ) {
|
|
80
|
+
|
|
81
|
+
const x = verts[ offset ];
|
|
82
|
+
const y = verts[ offset + 1 ];
|
|
83
|
+
const z = verts[ offset + 2 ];
|
|
84
|
+
|
|
85
|
+
verts[ offset ] = verts[ offset + 3 ];
|
|
86
|
+
verts[ offset + 1 ] = verts[ offset + 4 ];
|
|
87
|
+
verts[ offset + 2 ] = verts[ offset + 5 ];
|
|
88
|
+
|
|
89
|
+
verts[ offset + 3 ] = x;
|
|
90
|
+
verts[ offset + 4 ] = y;
|
|
91
|
+
verts[ offset + 5 ] = z;
|
|
92
|
+
|
|
93
|
+
offset += elemSize * 3;
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Traverse the object hierarchy collecting geometries and transforming them to world space
|
|
100
|
+
|
|
101
|
+
const meshGeometries = {};
|
|
102
|
+
const linesGeometries = {};
|
|
103
|
+
const condLinesGeometries = {};
|
|
104
|
+
|
|
105
|
+
object.updateMatrixWorld( true );
|
|
106
|
+
const normalMatrix = new Matrix3();
|
|
107
|
+
|
|
108
|
+
object.traverse( c => {
|
|
109
|
+
|
|
110
|
+
if ( c.isMesh | c.isLineSegments ) {
|
|
111
|
+
|
|
112
|
+
const elemSize = c.isMesh ? 3 : 2;
|
|
113
|
+
|
|
114
|
+
const matrixIsInverted = c.matrixWorld.determinant() < 0;
|
|
115
|
+
if ( matrixIsInverted ) {
|
|
116
|
+
|
|
117
|
+
permuteAttribute( c.geometry.attributes.position, elemSize );
|
|
118
|
+
permuteAttribute( c.geometry.attributes.normal, elemSize );
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
c.geometry.applyMatrix4( c.matrixWorld );
|
|
123
|
+
|
|
124
|
+
if ( c.isConditionalLine ) {
|
|
125
|
+
|
|
126
|
+
c.geometry.attributes.control0.applyMatrix4( c.matrixWorld );
|
|
127
|
+
c.geometry.attributes.control1.applyMatrix4( c.matrixWorld );
|
|
128
|
+
normalMatrix.getNormalMatrix( c.matrixWorld );
|
|
129
|
+
c.geometry.attributes.direction.applyNormalMatrix( normalMatrix );
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const geometries = c.isMesh ? meshGeometries : ( c.isConditionalLine ? condLinesGeometries : linesGeometries );
|
|
134
|
+
|
|
135
|
+
if ( Array.isArray( c.material ) ) {
|
|
136
|
+
|
|
137
|
+
for ( const groupIndex in c.geometry.groups ) {
|
|
138
|
+
|
|
139
|
+
const group = c.geometry.groups[ groupIndex ];
|
|
140
|
+
const mat = c.material[ group.materialIndex ];
|
|
141
|
+
const newGeometry = extractGroup( c.geometry, group, elemSize, c.isConditionalLine );
|
|
142
|
+
addGeometry( mat, newGeometry, geometries );
|
|
143
|
+
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
}
|
|
147
|
+
else addGeometry( c.material, c.geometry, geometries );
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
} );
|
|
152
|
+
|
|
153
|
+
// Create object with merged geometries
|
|
154
|
+
|
|
155
|
+
const mergedObject = new Group();
|
|
156
|
+
|
|
157
|
+
const meshMaterialsIds = Object.keys( meshGeometries );
|
|
158
|
+
for ( const i in meshMaterialsIds ) {
|
|
159
|
+
|
|
160
|
+
const meshGeometry = meshGeometries[ meshMaterialsIds[ i ] ];
|
|
161
|
+
const mergedGeometry = mergeBufferGeometries( meshGeometry.arr );
|
|
162
|
+
mergedObject.add( new Mesh( mergedGeometry, meshGeometry.mat ) );
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const linesMaterialsIds = Object.keys( linesGeometries );
|
|
167
|
+
for ( const i in linesMaterialsIds ) {
|
|
168
|
+
|
|
169
|
+
const lineGeometry = linesGeometries[ linesMaterialsIds[ i ] ];
|
|
170
|
+
const mergedGeometry = mergeBufferGeometries( lineGeometry.arr );
|
|
171
|
+
mergedObject.add( new LineSegments( mergedGeometry, lineGeometry.mat ) );
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const condLinesMaterialsIds = Object.keys( condLinesGeometries );
|
|
176
|
+
for ( const i in condLinesMaterialsIds ) {
|
|
177
|
+
|
|
178
|
+
const condLineGeometry = condLinesGeometries[ condLinesMaterialsIds[ i ] ];
|
|
179
|
+
const mergedGeometry = mergeBufferGeometries( condLineGeometry.arr );
|
|
180
|
+
const condLines = new LineSegments( mergedGeometry, condLineGeometry.mat );
|
|
181
|
+
condLines.isConditionalLine = true;
|
|
182
|
+
mergedObject.add( condLines );
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
mergedObject.userData.constructionStep = 0;
|
|
187
|
+
mergedObject.userData.numConstructionSteps = 1;
|
|
188
|
+
|
|
189
|
+
return mergedObject;
|
|
190
|
+
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export { LDrawUtils };
|
|
@@ -132,6 +132,12 @@ class VRButton {
|
|
|
132
132
|
|
|
133
133
|
supported ? showEnterVR() : showWebXRNotFound();
|
|
134
134
|
|
|
135
|
+
if ( supported && VRButton.xrSessionIsGranted ) {
|
|
136
|
+
|
|
137
|
+
button.click();
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
135
141
|
} );
|
|
136
142
|
|
|
137
143
|
return button;
|
|
@@ -164,6 +170,24 @@ class VRButton {
|
|
|
164
170
|
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
static xrSessionIsGranted = false;
|
|
174
|
+
|
|
175
|
+
static registerSessionGrantedListener() {
|
|
176
|
+
|
|
177
|
+
if ( 'xr' in navigator ) {
|
|
178
|
+
|
|
179
|
+
navigator.xr.addEventListener( 'sessiongranted', () => {
|
|
180
|
+
|
|
181
|
+
VRButton.xrSessionIsGranted = true;
|
|
182
|
+
|
|
183
|
+
} );
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
167
189
|
}
|
|
168
190
|
|
|
191
|
+
VRButton.registerSessionGrantedListener();
|
|
192
|
+
|
|
169
193
|
export { VRButton };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "super-three",
|
|
3
|
-
"version": "0.136.
|
|
3
|
+
"version": "0.136.1",
|
|
4
4
|
"description": "JavaScript 3D library",
|
|
5
5
|
"main": "build/three.js",
|
|
6
6
|
"module": "build/three.module.js",
|
|
@@ -55,6 +55,9 @@
|
|
|
55
55
|
"GPUTextureUsage": "readonly"
|
|
56
56
|
},
|
|
57
57
|
"rules": {
|
|
58
|
+
"no-throw-literal": [
|
|
59
|
+
"error"
|
|
60
|
+
],
|
|
58
61
|
"quotes": [
|
|
59
62
|
"error",
|
|
60
63
|
"single"
|
package/src/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const REVISION = '
|
|
1
|
+
export const REVISION = '137dev';
|
|
2
2
|
export const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };
|
|
3
3
|
export const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };
|
|
4
4
|
export const CullFaceNone = 0;
|
|
@@ -87,7 +87,6 @@ export const UnsignedShort5551Type = 1018;
|
|
|
87
87
|
export const UnsignedShort565Type = 1019;
|
|
88
88
|
export const UnsignedInt248Type = 1020;
|
|
89
89
|
export const AlphaFormat = 1021;
|
|
90
|
-
export const RGBFormat = 1022;
|
|
91
90
|
export const RGBAFormat = 1023;
|
|
92
91
|
export const LuminanceFormat = 1024;
|
|
93
92
|
export const LuminanceAlphaFormat = 1025;
|
|
@@ -126,20 +125,6 @@ export const RGBA_ASTC_10x10_Format = 37819;
|
|
|
126
125
|
export const RGBA_ASTC_12x10_Format = 37820;
|
|
127
126
|
export const RGBA_ASTC_12x12_Format = 37821;
|
|
128
127
|
export const RGBA_BPTC_Format = 36492;
|
|
129
|
-
export const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;
|
|
130
|
-
export const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;
|
|
131
|
-
export const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;
|
|
132
|
-
export const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;
|
|
133
|
-
export const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;
|
|
134
|
-
export const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;
|
|
135
|
-
export const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;
|
|
136
|
-
export const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;
|
|
137
|
-
export const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;
|
|
138
|
-
export const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;
|
|
139
|
-
export const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;
|
|
140
|
-
export const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;
|
|
141
|
-
export const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;
|
|
142
|
-
export const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;
|
|
143
128
|
export const LoopOnce = 2200;
|
|
144
129
|
export const LoopRepeat = 2201;
|
|
145
130
|
export const LoopPingPong = 2202;
|
|
@@ -191,3 +176,5 @@ export const StreamCopyUsage = 35042;
|
|
|
191
176
|
|
|
192
177
|
export const GLSL1 = '100';
|
|
193
178
|
export const GLSL3 = '300 es';
|
|
179
|
+
|
|
180
|
+
export const _SRGBAFormat = 1035; // fallback for WebGL 1
|
package/src/extras/ImageUtils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createElementNS } from '../utils.js';
|
|
2
|
+
import { SRGBToLinear } from '../math/Color.js';
|
|
2
3
|
|
|
3
4
|
let _canvas;
|
|
4
5
|
|
|
@@ -61,6 +62,68 @@ class ImageUtils {
|
|
|
61
62
|
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
static sRGBToLinear( image ) {
|
|
66
|
+
|
|
67
|
+
if ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||
|
|
68
|
+
( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||
|
|
69
|
+
( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
|
|
70
|
+
|
|
71
|
+
const canvas = createElementNS( 'canvas' );
|
|
72
|
+
|
|
73
|
+
canvas.width = image.width;
|
|
74
|
+
canvas.height = image.height;
|
|
75
|
+
|
|
76
|
+
const context = canvas.getContext( '2d' );
|
|
77
|
+
context.drawImage( image, 0, 0, image.width, image.height );
|
|
78
|
+
|
|
79
|
+
const imageData = context.getImageData( 0, 0, image.width, image.height );
|
|
80
|
+
const data = imageData.data;
|
|
81
|
+
|
|
82
|
+
for ( let i = 0; i < data.length; i ++ ) {
|
|
83
|
+
|
|
84
|
+
data[ i ] = SRGBToLinear( data[ i ] / 255 ) * 255;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
context.putImageData( imageData, 0, 0 );
|
|
89
|
+
|
|
90
|
+
return canvas;
|
|
91
|
+
|
|
92
|
+
} else if ( image.data ) {
|
|
93
|
+
|
|
94
|
+
const data = image.data.slice( 0 );
|
|
95
|
+
|
|
96
|
+
for ( let i = 0; i < data.length; i ++ ) {
|
|
97
|
+
|
|
98
|
+
if ( data instanceof Uint8Array || data instanceof Uint8ClampedArray ) {
|
|
99
|
+
|
|
100
|
+
data[ i ] = Math.floor( SRGBToLinear( data[ i ] / 255 ) * 255 );
|
|
101
|
+
|
|
102
|
+
} else {
|
|
103
|
+
|
|
104
|
+
// assuming float
|
|
105
|
+
|
|
106
|
+
data[ i ] = SRGBToLinear( data[ i ] );
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
data: data,
|
|
114
|
+
width: image.width,
|
|
115
|
+
height: image.height
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
} else {
|
|
119
|
+
|
|
120
|
+
console.warn( 'THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied.' );
|
|
121
|
+
return image;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
64
127
|
}
|
|
65
128
|
|
|
66
129
|
export { ImageUtils };
|