@p100-web/core-three 100.2.18 → 100.2.19
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/animations/ModelAnimation.d.ts.map +1 -1
- package/dist/animations/ModelAnimation.js +2 -3
- package/dist/animations/ModelAnimation.js.map +1 -1
- package/dist/pcomponents/PAnimator.d.ts +0 -2
- package/dist/pcomponents/PAnimator.d.ts.map +1 -1
- package/dist/pcomponents/PAnimator.js +53 -35
- package/dist/pcomponents/PAnimator.js.map +1 -1
- package/dist/pcomponents/PMaskedMaterial.js +51 -51
- package/package.json +33 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelAnimation.d.ts","sourceRoot":"","sources":["../../src/animations/ModelAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,OAAO,CAAC;AAE9E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,eAAe;IAC5D,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;gBAEZ,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe;
|
|
1
|
+
{"version":3,"file":"ModelAnimation.d.ts","sourceRoot":"","sources":["../../src/animations/ModelAnimation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAwB,MAAM,OAAO,CAAC;AAE9E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,eAAe;IAC5D,IAAI,EAAE,MAAM,CAAC;IAEb,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,eAAe,CAAC;gBAEZ,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe;IAS1D,WAAW,IAAI,MAAM;IAIrB,mBAAmB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAIzC,sBAAsB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAI5C,SAAS,IAAI,OAAO;IAIpB,IAAI,IAAI,IAAI;IAIZ,WAAW,IAAI,IAAI;IAInB,IAAI,IAAI,IAAI;IAIZ,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAI5B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI9B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAIxB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKzB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI3B,OAAO,IAAI,MAAM;IAIjB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;CAGhC"}
|
|
@@ -4,6 +4,8 @@ export default class ModelAnimation {
|
|
|
4
4
|
this.name = action.getClip().name;
|
|
5
5
|
this.mixer = mixer;
|
|
6
6
|
this.action = action;
|
|
7
|
+
this.setLoop(false);
|
|
8
|
+
this.setClamp(true);
|
|
7
9
|
}
|
|
8
10
|
getDuration() {
|
|
9
11
|
return this.action.getClip().duration || 0;
|
|
@@ -36,9 +38,6 @@ export default class ModelAnimation {
|
|
|
36
38
|
this.mixer.update(dt);
|
|
37
39
|
}
|
|
38
40
|
reset(time) {
|
|
39
|
-
this.action.play();
|
|
40
|
-
this.action.paused = true;
|
|
41
|
-
this.action.enabled = true;
|
|
42
41
|
this.action.time = time;
|
|
43
42
|
this.mixer.update(0);
|
|
44
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelAnimation.js","sourceRoot":"","sources":["../../src/animations/ModelAnimation.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,QAAQ,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAE9E,MAAM,CAAC,OAAO,OAAO,cAAc;IAMjC,YAAY,KAAqB,E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AC;IACrB,CAAC;IAED,OAAO,CAAC,IAAa;QACnB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAED,QAAQ,CAAC,KAAc;QACrB,IAAI,CAAC,MAAM,CAAC,iBAAiB,GAAG,KAAK,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,EAAU;QACf,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,IAAY;QAChB,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,SAAS,CAAC,KAAc;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -4,7 +4,6 @@ import { type IModelAnimation, INodeEventListener, INodeEventSender, NodeEvents,
|
|
|
4
4
|
export default class PAnimator extends PAnimatorBase implements INodeEventListener {
|
|
5
5
|
protected _animation: IModelAnimation | null;
|
|
6
6
|
private _playedDuration;
|
|
7
|
-
private _segmentDuration;
|
|
8
7
|
private _playing;
|
|
9
8
|
getModelComponent(): PModelGLTF | null;
|
|
10
9
|
render(): void;
|
|
@@ -19,7 +18,6 @@ export default class PAnimator extends PAnimatorBase implements INodeEventListen
|
|
|
19
18
|
onFinished: () => void;
|
|
20
19
|
callback_onStop(): void;
|
|
21
20
|
callback_onReset(value: Payload): void;
|
|
22
|
-
updateSegment: (dt: number) => void;
|
|
23
21
|
update: (dt: number) => void;
|
|
24
22
|
}
|
|
25
23
|
//# sourceMappingURL=PAnimator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PAnimator.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PAnimator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,KAAK,eAAe,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,SAAS,IAAI,aAAa,EAC1B,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,OAAO,SACnB,SAAQ,aACR,YAAW,kBAAkB;IAE7B,SAAS,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAQ;IAEpD,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"PAnimator.d.ts","sourceRoot":"","sources":["../../src/pcomponents/PAnimator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,KAAK,eAAe,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,SAAS,IAAI,aAAa,EAC1B,OAAO,EACR,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,OAAO,SACnB,SAAQ,aACR,YAAW,kBAAkB;IAE7B,SAAS,CAAC,UAAU,EAAE,eAAe,GAAG,IAAI,CAAQ;IAEpD,OAAO,CAAC,eAAe,CAAK;IAC5B,OAAO,CAAC,QAAQ,CAAS;IAEzB,iBAAiB,IAAI,UAAU,GAAG,IAAI;IAItC,MAAM,IAAI,IAAI;IAUd,QAAQ;IAeR,WAAW,GACT,WAAW,gBAAgB,EAC3B,MAAM,UAAU,EAChB,OAAO,KAAK,KACX,IAAI,CAaL;IAEF,iBAAiB,IAAI,MAAM,EAAE;IAK7B;;OAEG;IACH,OAAO,CAAC,KAAK;IAgBb,eAAe,IAAI,IAAI;IA+CvB,UAAU,aAIR;IAEF,eAAe,IAAI,IAAI;IAQvB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IActC,MAAM,GAAI,IAAI,MAAM,UAoBlB;CAOH"}
|
|
@@ -4,7 +4,6 @@ export default class PAnimator extends PAnimatorBase {
|
|
|
4
4
|
super(...arguments);
|
|
5
5
|
this._animation = null;
|
|
6
6
|
this._playedDuration = 0;
|
|
7
|
-
this._segmentDuration = 0;
|
|
8
7
|
this._playing = false;
|
|
9
8
|
//
|
|
10
9
|
// INodeEventListener
|
|
@@ -25,11 +24,13 @@ export default class PAnimator extends PAnimatorBase {
|
|
|
25
24
|
this.onFinished = () => {
|
|
26
25
|
this._playedDuration = 0;
|
|
27
26
|
this._stop(true);
|
|
28
|
-
this.outport_onFinished?.emit(
|
|
27
|
+
this.outport_onFinished?.emit(this.clip);
|
|
29
28
|
};
|
|
30
|
-
this.
|
|
29
|
+
this.update = (dt) => {
|
|
31
30
|
this._playedDuration += dt;
|
|
32
|
-
|
|
31
|
+
this._animation.setTime(this._playedDuration);
|
|
32
|
+
this._animation?.update(0);
|
|
33
|
+
if (this._playedDuration >= this.to) {
|
|
33
34
|
if (this.loop) {
|
|
34
35
|
this._playedDuration = 0;
|
|
35
36
|
this._animation.setTime(this.from);
|
|
@@ -43,14 +44,14 @@ export default class PAnimator extends PAnimatorBase {
|
|
|
43
44
|
}
|
|
44
45
|
// Remove events and callbacks
|
|
45
46
|
this.onFinished();
|
|
46
|
-
return;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
this._animation?.update(dt);
|
|
50
|
-
};
|
|
51
|
-
this.update = (dt) => {
|
|
52
|
-
this._animation.update(dt);
|
|
53
49
|
};
|
|
50
|
+
// update = (dt: number) => {
|
|
51
|
+
// this._playedDuration += dt;
|
|
52
|
+
// this._animation!.setTime(this._playedDuration);
|
|
53
|
+
// this._animation!.update(0);
|
|
54
|
+
// };
|
|
54
55
|
}
|
|
55
56
|
getModelComponent() {
|
|
56
57
|
return this.findComponent("PModelGLTF");
|
|
@@ -82,49 +83,52 @@ export default class PAnimator extends PAnimatorBase {
|
|
|
82
83
|
* Stop playback and remove event listeners
|
|
83
84
|
*/
|
|
84
85
|
_stop(emitOnStopped) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
else {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
86
|
+
this.context.getCanvas().unregisterUpdate(this.update);
|
|
87
|
+
// if (this.segment) {
|
|
88
|
+
// this.context.getCanvas()!.unregisterUpdate(this.updateSegment);
|
|
89
|
+
// } else {
|
|
90
|
+
// this.context.getCanvas()!.unregisterUpdate(this.update);
|
|
91
|
+
// this._animation?.removeFinishedListener(this.onFinished);
|
|
92
|
+
// }
|
|
92
93
|
this._playing = false;
|
|
93
94
|
// Always call on stop
|
|
94
95
|
if (emitOnStopped)
|
|
95
|
-
this.outport_onStopped?.emit(
|
|
96
|
+
this.outport_onStopped?.emit(this.clip);
|
|
96
97
|
}
|
|
97
98
|
callback_onPlay() {
|
|
98
99
|
if (this.clip === "")
|
|
99
100
|
return;
|
|
100
101
|
if (this._playing) {
|
|
101
|
-
console.log("
|
|
102
|
+
console.log("Animation was already running");
|
|
103
|
+
this._stop(false);
|
|
102
104
|
}
|
|
103
105
|
if (this._animation !== null) {
|
|
104
|
-
// if (this._animation.isRunning()) {
|
|
105
|
-
// this.context.error("Animation was already running");
|
|
106
|
-
// return;
|
|
107
|
-
// }
|
|
108
|
-
this._playedDuration = 0;
|
|
109
|
-
this._segmentDuration = this.to - this.from;
|
|
110
|
-
this._animation.setPaused(false);
|
|
111
106
|
if (this.segment) {
|
|
112
|
-
//
|
|
113
|
-
this.
|
|
114
|
-
|
|
107
|
+
// Segment duration
|
|
108
|
+
this._playedDuration = this.from;
|
|
109
|
+
// Set start time
|
|
115
110
|
this._animation.setTime(this.from);
|
|
116
|
-
|
|
111
|
+
// Register update callback
|
|
112
|
+
this.context.getCanvas().registerUpdate(this.update);
|
|
117
113
|
}
|
|
118
114
|
else {
|
|
119
|
-
|
|
120
|
-
this.
|
|
121
|
-
this._animation.
|
|
122
|
-
this.
|
|
115
|
+
// Whole clip duration
|
|
116
|
+
this.from = 0;
|
|
117
|
+
this.to = this._animation.getDuration();
|
|
118
|
+
this._playedDuration = this.from;
|
|
119
|
+
// Set start time
|
|
120
|
+
this._animation.setTime(this.from);
|
|
121
|
+
// Register update callback
|
|
123
122
|
this.context.getCanvas().registerUpdate(this.update);
|
|
123
|
+
// this._animation.addFinishedListener(this.onFinished);
|
|
124
|
+
// this.context.getCanvas()!.registerUpdate(this.update);
|
|
124
125
|
}
|
|
125
126
|
this._playing = true;
|
|
126
|
-
this._animation.
|
|
127
|
-
|
|
127
|
+
if (!this._animation.isRunning()) {
|
|
128
|
+
this._animation.play();
|
|
129
|
+
this._animation.setPaused(true);
|
|
130
|
+
}
|
|
131
|
+
this.outport_onPlay?.emit(this.clip);
|
|
128
132
|
}
|
|
129
133
|
else {
|
|
130
134
|
this.context.error("Animation not found: " + this.clip);
|
|
@@ -143,9 +147,23 @@ export default class PAnimator extends PAnimatorBase {
|
|
|
143
147
|
const second = value ? parseFloat(value) : 0;
|
|
144
148
|
if (this.clip === "" || !this._animation)
|
|
145
149
|
return;
|
|
150
|
+
if (!this._animation.isRunning()) {
|
|
151
|
+
this._animation.play();
|
|
152
|
+
this._animation.setPaused(true);
|
|
153
|
+
}
|
|
146
154
|
this._playedDuration = second;
|
|
147
155
|
this._stop(false);
|
|
148
156
|
this._animation.reset(second);
|
|
149
157
|
}
|
|
150
158
|
}
|
|
159
|
+
/*
|
|
160
|
+
action.play(); // must be enabled
|
|
161
|
+
action.paused = true; // prevent automatic time progression
|
|
162
|
+
|
|
163
|
+
// set time manually
|
|
164
|
+
action.time = 1.5;
|
|
165
|
+
|
|
166
|
+
// force evaluation
|
|
167
|
+
mixer.update(0);
|
|
168
|
+
*/
|
|
151
169
|
//# sourceMappingURL=PAnimator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PAnimator.js","sourceRoot":"","sources":["../../src/pcomponents/PAnimator.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,UAAU,EACV,SAAS,IAAI,aAAa,GAE3B,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,OAAO,SACnB,SAAQ,aAAa;IADvB;;QAIY,eAAU,GAA2B,IAAI,CAAC;QAE5C,oBAAe,GAAG,CAAC,CAAC;QACpB,
|
|
1
|
+
{"version":3,"file":"PAnimator.js","sourceRoot":"","sources":["../../src/pcomponents/PAnimator.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,UAAU,EACV,SAAS,IAAI,aAAa,GAE3B,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,OAAO,SACnB,SAAQ,aAAa;IADvB;;QAIY,eAAU,GAA2B,IAAI,CAAC;QAE5C,oBAAe,GAAG,CAAC,CAAC;QACpB,aAAQ,GAAG,KAAK,CAAC;QA2BzB,EAAE;QACF,sBAAsB;QACtB,EAAE;QAEF,gBAAW,GAAG,CACZ,SAA2B,EAC3B,IAAgB,EAChB,KAAY,EACN,EAAE;YACR,IAAI,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC;gBAAE,OAAO;YAE7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;YACpB,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;YAE5B,4BAA4B;YAC5B,IAAI,SAAS,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACzC,IAAI,CAAC,UAAU,GAAI,SAAwB,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACpE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,KAAK,IAAI,CAA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,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAQD,eAAe;QACb,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE;YAAE,OAAO;QAC7B,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,4BAA4B;QAC5B,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC;QAC9C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,gBAAgB,CAAC,KAAc;QAC7B,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7C,IAAI,IAAI,CAAC,IAAI,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAEjD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC;YACjC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;CA6BF;AAED;;;;;;;;;EASE"}
|
|
@@ -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.19",
|
|
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.19",
|
|
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
|
+
}
|