@p100-web/core-three 100.2.12 → 100.2.13
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/dist/pcomponents/PMaskedMaterial.js +51 -51
- package/package.json +33 -33
|
@@ -139,60 +139,60 @@ function createChromaKeyMaterial(args) {
|
|
|
139
139
|
keySoftness: { value: 0.001 }, // squared threshold
|
|
140
140
|
stereoMultiplier: { value: 1 }, // squared threshold
|
|
141
141
|
},
|
|
142
|
-
vertexShader: `
|
|
143
|
-
varying vec2 vUv;
|
|
144
|
-
void main() {
|
|
145
|
-
vUv = uv;
|
|
146
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
147
|
-
}
|
|
142
|
+
vertexShader: `
|
|
143
|
+
varying vec2 vUv;
|
|
144
|
+
void main() {
|
|
145
|
+
vUv = uv;
|
|
146
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
147
|
+
}
|
|
148
148
|
`,
|
|
149
149
|
fragmentShader: args.transparent
|
|
150
|
-
? `
|
|
151
|
-
uniform sampler2D map;
|
|
152
|
-
uniform vec3 keyColor;
|
|
153
|
-
uniform float keyThreshold;
|
|
154
|
-
uniform float keySoftness;
|
|
155
|
-
uniform float stereoMultiplier;
|
|
156
|
-
varying vec2 vUv;
|
|
157
|
-
|
|
158
|
-
void main() {
|
|
159
|
-
vec2 uv = vUv;
|
|
160
|
-
uv.y *= stereoMultiplier;
|
|
161
|
-
vec4 col = texture2D(map, uv);
|
|
162
|
-
|
|
163
|
-
// squared distance to key color
|
|
164
|
-
vec3 diff = col.rgb - keyColor;
|
|
165
|
-
float distSq = dot(diff, diff);
|
|
166
|
-
|
|
167
|
-
// Smooth alpha:
|
|
168
|
-
// distSq <= keyThreshold → fully transparent
|
|
169
|
-
// distSq >= keyThreshold+softness → fully opaque
|
|
170
|
-
float alpha = smoothstep(keyThreshold, keyThreshold + keySoftness, distSq);
|
|
171
|
-
|
|
172
|
-
// multiply original texture alpha as well
|
|
173
|
-
gl_FragColor = vec4(col.rgb, col.a * alpha);
|
|
174
|
-
}
|
|
150
|
+
? `
|
|
151
|
+
uniform sampler2D map;
|
|
152
|
+
uniform vec3 keyColor;
|
|
153
|
+
uniform float keyThreshold;
|
|
154
|
+
uniform float keySoftness;
|
|
155
|
+
uniform float stereoMultiplier;
|
|
156
|
+
varying vec2 vUv;
|
|
157
|
+
|
|
158
|
+
void main() {
|
|
159
|
+
vec2 uv = vUv;
|
|
160
|
+
uv.y *= stereoMultiplier;
|
|
161
|
+
vec4 col = texture2D(map, uv);
|
|
162
|
+
|
|
163
|
+
// squared distance to key color
|
|
164
|
+
vec3 diff = col.rgb - keyColor;
|
|
165
|
+
float distSq = dot(diff, diff);
|
|
166
|
+
|
|
167
|
+
// Smooth alpha:
|
|
168
|
+
// distSq <= keyThreshold → fully transparent
|
|
169
|
+
// distSq >= keyThreshold+softness → fully opaque
|
|
170
|
+
float alpha = smoothstep(keyThreshold, keyThreshold + keySoftness, distSq);
|
|
171
|
+
|
|
172
|
+
// multiply original texture alpha as well
|
|
173
|
+
gl_FragColor = vec4(col.rgb, col.a * alpha);
|
|
174
|
+
}
|
|
175
175
|
`
|
|
176
|
-
: `
|
|
177
|
-
uniform sampler2D map;
|
|
178
|
-
uniform vec3 keyColor;
|
|
179
|
-
uniform float keyThreshold;
|
|
180
|
-
uniform float stereoMultiplier;
|
|
181
|
-
varying vec2 vUv;
|
|
182
|
-
|
|
183
|
-
void main() {
|
|
184
|
-
vec2 uv = vUv;
|
|
185
|
-
uv.y *= stereoMultiplier;
|
|
186
|
-
vec4 col = texture2D(map, uv);
|
|
187
|
-
|
|
188
|
-
// squared distance to key color
|
|
189
|
-
vec3 diff = col.rgb - keyColor;
|
|
190
|
-
float distSq = dot(diff, diff);
|
|
191
|
-
|
|
192
|
-
// branch-free alpha mask
|
|
193
|
-
if (distSq < keyThreshold) discard;
|
|
194
|
-
gl_FragColor = vec4(col.rgb, 1);
|
|
195
|
-
}
|
|
176
|
+
: `
|
|
177
|
+
uniform sampler2D map;
|
|
178
|
+
uniform vec3 keyColor;
|
|
179
|
+
uniform float keyThreshold;
|
|
180
|
+
uniform float stereoMultiplier;
|
|
181
|
+
varying vec2 vUv;
|
|
182
|
+
|
|
183
|
+
void main() {
|
|
184
|
+
vec2 uv = vUv;
|
|
185
|
+
uv.y *= stereoMultiplier;
|
|
186
|
+
vec4 col = texture2D(map, uv);
|
|
187
|
+
|
|
188
|
+
// squared distance to key color
|
|
189
|
+
vec3 diff = col.rgb - keyColor;
|
|
190
|
+
float distSq = dot(diff, diff);
|
|
191
|
+
|
|
192
|
+
// branch-free alpha mask
|
|
193
|
+
if (distSq < keyThreshold) discard;
|
|
194
|
+
gl_FragColor = vec4(col.rgb, 1);
|
|
195
|
+
}
|
|
196
196
|
`,
|
|
197
197
|
//
|
|
198
198
|
});
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@p100-web/core-three",
|
|
3
|
-
"private": false,
|
|
4
|
-
"version": "100.2.
|
|
5
|
-
"author": "Peter Drugge",
|
|
6
|
-
"license": "ISC",
|
|
7
|
-
"description": "",
|
|
8
|
-
"devDependencies": {
|
|
9
|
-
"eslint": "^8.57.0",
|
|
10
|
-
"@types/three": "^0.179.0",
|
|
11
|
-
"typescript": "^5.4.2"
|
|
12
|
-
},
|
|
13
|
-
"peerDependencies": {
|
|
14
|
-
"@p100-web/core": "^100.2.
|
|
15
|
-
"three": "^0.179.1",
|
|
16
|
-
"troika-three-text": "^0.52.4",
|
|
17
|
-
"@tweenjs/tween.js": "^25.0.0"
|
|
18
|
-
},
|
|
19
|
-
"files": ["dist"],
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"detect-gpu": "^5.0.70"
|
|
22
|
-
},
|
|
23
|
-
"scripts": {
|
|
24
|
-
"clean": "rimraf dist",
|
|
25
|
-
"build": "tsc -p tsconfig.json"
|
|
26
|
-
},
|
|
27
|
-
"exports": {
|
|
28
|
-
".": {
|
|
29
|
-
"import": "./dist/index.js",
|
|
30
|
-
"types": "./dist/index.d.ts"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@p100-web/core-three",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "100.2.13",
|
|
5
|
+
"author": "Peter Drugge",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"description": "",
|
|
8
|
+
"devDependencies": {
|
|
9
|
+
"eslint": "^8.57.0",
|
|
10
|
+
"@types/three": "^0.179.0",
|
|
11
|
+
"typescript": "^5.4.2"
|
|
12
|
+
},
|
|
13
|
+
"peerDependencies": {
|
|
14
|
+
"@p100-web/core": "^100.2.13",
|
|
15
|
+
"three": "^0.179.1",
|
|
16
|
+
"troika-three-text": "^0.52.4",
|
|
17
|
+
"@tweenjs/tween.js": "^25.0.0"
|
|
18
|
+
},
|
|
19
|
+
"files": ["dist"],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"detect-gpu": "^5.0.70"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "rimraf dist",
|
|
25
|
+
"build": "tsc -p tsconfig.json"
|
|
26
|
+
},
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"import": "./dist/index.js",
|
|
30
|
+
"types": "./dist/index.d.ts"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|