Skip to content

Commit 9c07f55

Browse files
authored
fix: add FullScreenQuad directly to maintain bundle less support + Ou… (#77)
* fix: copy Pass/FullScreenQuad directly to maintain bundle less support + Outlines use empty {} as default input
1 parent b3f9eab commit 9c07f55

File tree

5 files changed

+61
-46
lines changed

5 files changed

+61
-46
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
"build-storybook": "build-storybook"
6060
},
6161
"dependencies": {
62-
"glsl-noise": "^0.0.0",
63-
"three-stdlib": "^2.34.0"
62+
"glsl-noise": "^0.0.0"
6463
},
6564
"devDependencies": {
6665
"@babel/core": "^7.14.3",

src/core/MeshPortalMaterial.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as THREE from 'three'
22
import { shaderMaterial } from './shaderMaterial'
33
import { version } from '../helpers/constants'
4-
import { FullScreenQuad } from 'three-stdlib'
4+
import { FullScreenQuad } from '../helpers/Pass'
55

66
export type PortalMaterialType = {
77
resolution: THREE.Vector2

src/core/Outlines.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function Outlines({
9898
thickness = 0.05,
9999
angle = Math.PI,
100100
gl,
101-
}: Partial<OutlinesProps>): OutlinesType {
101+
}: Partial<OutlinesProps> = {}): OutlinesType {
102102
const group = new THREE.Group()
103103

104104
let shapeProps: OutlinesProps = {

src/helpers/Pass.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { OrthographicCamera, PlaneGeometry, Mesh, Material, Renderer, WebGLRenderer, WebGLRenderTarget } from 'three'
2+
3+
class Pass {
4+
// if set to true, the pass is processed by the composer
5+
public enabled = true
6+
7+
// if set to true, the pass indicates to swap read and write buffer after rendering
8+
public needsSwap = true
9+
10+
// if set to true, the pass clears its buffer before rendering
11+
public clear = false
12+
13+
// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
14+
public renderToScreen = false
15+
16+
public setSize(width: number, height: number): void {}
17+
18+
public render(
19+
renderer: WebGLRenderer,
20+
writeBuffer: WebGLRenderTarget,
21+
readBuffer: WebGLRenderTarget,
22+
deltaTime: number,
23+
maskActive?: unknown
24+
): void {
25+
console.error('THREE.Pass: .render() must be implemented in derived pass.')
26+
}
27+
28+
public dispose() {}
29+
}
30+
31+
// Helper for passes that need to fill the viewport with a single quad.
32+
class FullScreenQuad<TMaterial extends Material = Material> {
33+
public camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)
34+
public geometry = new PlaneGeometry(2, 2)
35+
private mesh: Mesh<PlaneGeometry, TMaterial>
36+
37+
constructor(material: TMaterial) {
38+
this.mesh = new Mesh(this.geometry, material)
39+
}
40+
41+
public get material(): TMaterial {
42+
return this.mesh.material
43+
}
44+
45+
public set material(value: TMaterial) {
46+
this.mesh.material = value
47+
}
48+
49+
public dispose(): void {
50+
this.mesh.geometry.dispose()
51+
}
52+
53+
public render(renderer: Renderer): void {
54+
renderer.render(this.mesh, this.camera)
55+
}
56+
}
57+
58+
export { Pass, FullScreenQuad }

yarn.lock

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,11 +3175,6 @@
31753175
dependencies:
31763176
"@babel/types" "^7.3.0"
31773177

3178-
"@types/draco3d@^1.4.0":
3179-
version "1.4.2"
3180-
resolved "https://registry.yarnpkg.com/@types/draco3d/-/draco3d-1.4.2.tgz#7faccb809db2a5e19b9efb97c5f2eb9d64d527ea"
3181-
integrity sha512-goh23EGr6CLV6aKPwN1p8kBD/7tT5V/bLpToSbarKrwVejqNrspVrv8DhliteYkkhZYrlq/fwKZRRUzH4XN88w==
3182-
31833178
"@types/eslint-scope@^3.7.3":
31843179
version "3.7.4"
31853180
resolved "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz"
@@ -3350,11 +3345,6 @@
33503345
resolved "https://registry.npmjs.org/@types/npmlog/-/npmlog-4.1.4.tgz"
33513346
integrity sha512-WKG4gTr8przEZBiJ5r3s8ZIAoMXNbOgQ+j/d5O4X3x6kZJRLNvyUJuUK/KoG3+8BaOHPhp2m7WC6JKKeovDSzQ==
33523347

3353-
"@types/offscreencanvas@^2019.6.4":
3354-
version "2019.7.0"
3355-
resolved "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.0.tgz"
3356-
integrity sha512-PGcyveRIpL1XIqK8eBsmRBt76eFgtzuPiSTyKHZxnGemp2yzGzWpjYKAfK3wIMiU7eH+851yEpiuP8JZerTmWg==
3357-
33583348
"@types/parse-json@^4.0.0":
33593349
version "4.0.0"
33603350
resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz"
@@ -3466,11 +3456,6 @@
34663456
resolved "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.1.tgz"
34673457
integrity sha512-xlFXPfgJR5vIuDefhaHuUM9uUgvPaXB6GKdXy2gdEh8gBWQZ2ul24AJz3foUd8NNKlSTQuWYJpCb1/pL81m1KQ==
34683458

3469-
"@types/webxr@^0.5.2":
3470-
version "0.5.4"
3471-
resolved "https://registry.yarnpkg.com/@types/webxr/-/webxr-0.5.4.tgz#3d55a6427f9281d456843d754c99bf7804657fe3"
3472-
integrity sha512-41gfGLTtqXZhcmoDlLDHqMJDuwAMwhHwXf9Q2job3TUBsvkNfPNI/3IWVEtLH4tyY1ElWtfwIaoNeqeEX238/Q==
3473-
34743459
"@types/yargs-parser@*":
34753460
version "21.0.0"
34763461
resolved "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz"
@@ -6200,11 +6185,6 @@ dotenv@^8.0.0:
62006185
resolved "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz"
62016186
integrity sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==
62026187

6203-
draco3d@^1.4.1:
6204-
version "1.5.2"
6205-
resolved "https://registry.npmjs.org/draco3d/-/draco3d-1.5.2.tgz"
6206-
integrity sha512-AeRQ25Fb29c14vpjnh167UGW0nGY0ZpEM3ld+zEXoEySlmEXcXfsCHZeTgo5qXH925V1JsdjrzasdaQ22/vXog==
6207-
62086188
duplexer2@~0.1.0:
62096189
version "0.1.4"
62106190
resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz"
@@ -6979,11 +6959,6 @@ fetch-retry@^5.0.2:
69796959
resolved "https://registry.npmjs.org/fetch-retry/-/fetch-retry-5.0.4.tgz"
69806960
integrity sha512-LXcdgpdcVedccGg0AZqg+S8lX/FCdwXD92WNZ5k5qsb0irRhSFsBOpcJt7oevyqT2/C2nEE0zSFNdBEpj3YOSw==
69816961

6982-
fflate@^0.6.9:
6983-
version "0.6.10"
6984-
resolved "https://registry.npmjs.org/fflate/-/fflate-0.6.10.tgz"
6985-
integrity sha512-IQrh3lEPM93wVCEczc9SaAOvkmcoQn/G8Bo1e8ZPlY3X3bnAxWaBdvTdvM1hP62iZp0BXWDy4vTAy4fF0+Dlpg==
6986-
69876962
fflate@~0.8.2:
69886963
version "0.8.2"
69896964
resolved "https://registry.yarnpkg.com/fflate/-/fflate-0.8.2.tgz#fc8631f5347812ad6028bbe4a2308b2792aa1dea"
@@ -11771,11 +11746,6 @@ postcss@^8.2.15:
1177111746
picocolors "^1.0.0"
1177211747
source-map-js "^1.0.2"
1177311748

11774-
potpack@^1.0.1:
11775-
version "1.0.2"
11776-
resolved "https://registry.npmjs.org/potpack/-/potpack-1.0.2.tgz"
11777-
integrity sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==
11778-
1177911749
prelude-ls@^1.2.1:
1178011750
version "1.2.1"
1178111751
resolved "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz"
@@ -13833,18 +13803,6 @@ text-table@^0.2.0, text-table@~0.2.0:
1383313803
resolved "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz"
1383413804
integrity "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw=="
1383513805

13836-
three-stdlib@^2.34.0:
13837-
version "2.34.0"
13838-
resolved "https://registry.yarnpkg.com/three-stdlib/-/three-stdlib-2.34.0.tgz#bc191d92037ddcc3e4d5a4ae1bd46a199a857b5b"
13839-
integrity sha512-U5qJYWgUKBFJqr1coMSbczA964uvouzBjQbtJlaI9LfMwy7hr+kc1Mfh0gqi/2872KmGu9utgff6lj8Oti8+VQ==
13840-
dependencies:
13841-
"@types/draco3d" "^1.4.0"
13842-
"@types/offscreencanvas" "^2019.6.4"
13843-
"@types/webxr" "^0.5.2"
13844-
draco3d "^1.4.1"
13845-
fflate "^0.6.9"
13846-
potpack "^1.0.1"
13847-
1384813806
three@^0.166.1:
1384913807
version "0.166.1"
1385013808
resolved "https://registry.yarnpkg.com/three/-/three-0.166.1.tgz#322cfc48fff4e751cd47d61fd1558c387d098d7c"

0 commit comments

Comments
 (0)