Skip to content

Commit b138255

Browse files
committed
docs(soba): add mesh transmission material story
1 parent 827d0cc commit b138255

File tree

4 files changed

+704
-828
lines changed

4 files changed

+704
-828
lines changed
Binary file not shown.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
import { NgIf } from '@angular/common';
2+
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
3+
import { NgtsOrbitControls } from 'angular-three-soba/controls';
4+
import { injectNgtsGLTFLoader } from 'angular-three-soba/loaders';
5+
import { NgtsMeshTranmissionMaterial } from 'angular-three-soba/materials';
6+
import { NgtsAccumulativeShadows, NgtsCenter, NgtsEnvironment, NgtsRandomizedLights } from 'angular-three-soba/staging';
7+
import * as THREE from 'three';
8+
import { makeCanvasOptions, makeDecorators, makeStoryFunction } from '../setup-canvas';
9+
10+
// https://sketchfab.com/3d-models/gelatinous-cube-e08385238f4d4b59b012233a9fbdca21
11+
@Component({
12+
selector: 'transmission-gelatinous-cube',
13+
standalone: true,
14+
template: `
15+
<ngt-group *ngIf="cubeGLTF() as cubeGLTF" [dispose]="null">
16+
<ngt-mesh [geometry]="cubeGLTF.nodes.cube1.geometry" [position]="[-0.56, 0.38, -0.11]">
17+
<ngts-mesh-transmission-material
18+
[background]="background"
19+
[backside]="false"
20+
[samples]="10"
21+
[resolution]="2048"
22+
[transmission]="1"
23+
[roughness]="0"
24+
[thickness]="3.5"
25+
[ior]="1.5"
26+
[chromaticAberration]="0.06"
27+
[anisotropy]="0.1"
28+
[distortion]="0.0"
29+
[distortionScale]="0.3"
30+
[temporalDistortion]="0.5"
31+
[clearcoat]="1"
32+
[attenuationDistance]="0.5"
33+
attenuationColor="#ffffff"
34+
color="#c9ffa1"
35+
/>
36+
</ngt-mesh>
37+
<ngt-mesh
38+
[castShadow]="true"
39+
[renderOrder]="-100"
40+
[geometry]="cubeGLTF.nodes.cube2.geometry"
41+
[material]="cubeGLTF.materials.cube_mat"
42+
[position]="[-0.56, 0.38, -0.11]"
43+
>
44+
<ngt-value [rawValue]="FrontSide" attach="material.side" />
45+
</ngt-mesh>
46+
<ngt-mesh
47+
[geometry]="cubeGLTF.nodes.bubbles.geometry"
48+
[material]="cubeGLTF.materials.cube_bubbles_mat"
49+
[position]="[-0.56, 0.38, -0.11]"
50+
/>
51+
<ngt-group [position]="[-0.56, 0.38, -0.41]">
52+
<ngt-mesh [geometry]="cubeGLTF.nodes.arrows.geometry" [material]="cubeGLTF.materials.weapons_mat" />
53+
<ngt-mesh [geometry]="cubeGLTF.nodes.skeleton_1.geometry" [material]="cubeGLTF.materials.skele_mat" />
54+
<ngt-mesh [geometry]="cubeGLTF.nodes.skeleton_2.geometry" [material]="cubeGLTF.materials.weapons_mat">
55+
<ngt-value [rawValue]="FrontSide" attach="material.side" />
56+
</ngt-mesh>
57+
</ngt-group>
58+
</ngt-group>
59+
`,
60+
imports: [NgIf, NgtsMeshTranmissionMaterial],
61+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
62+
})
63+
class GelatinousCube {
64+
FrontSide = THREE.FrontSide;
65+
background = new THREE.Color('#839681');
66+
cubeGLTF = injectNgtsGLTFLoader(() => 'soba/gelatinous_cube.glb');
67+
}
68+
69+
@Component({
70+
standalone: true,
71+
template: `
72+
<ngt-ambient-light />
73+
<ngt-group [position]="[0, -2.5, 0]">
74+
<ngts-center [top]="true">
75+
<transmission-gelatinous-cube />
76+
</ngts-center>
77+
<ngts-accumulative-shadows
78+
[temporal]="true"
79+
[frames]="100"
80+
[alphaTest]="0.9"
81+
[colorBlend]="1"
82+
[opacity]="0.8"
83+
[scale]="20"
84+
color="#3ead5d"
85+
>
86+
<ngts-randomized-lights
87+
[radius]="10"
88+
[ambient]="0.5"
89+
[intensity]="Math.PI"
90+
[position]="[2.5, 8, -2.5]"
91+
[bias]="0.001"
92+
/>
93+
</ngts-accumulative-shadows>
94+
</ngt-group>
95+
<ngts-orbit-controls
96+
[minPolarAngle]="0"
97+
[maxPolarAngle]="Math.PI / 2"
98+
[autoRotate]="true"
99+
[autoRotateSpeed]="0.05"
100+
[makeDefault]="true"
101+
/>
102+
<ngts-environment
103+
files="https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/dancing_hall_1k.hdr"
104+
[background]="true"
105+
[blur]="1"
106+
/>
107+
`,
108+
imports: [
109+
GelatinousCube,
110+
NgtsCenter,
111+
NgtsAccumulativeShadows,
112+
NgtsRandomizedLights,
113+
NgtsOrbitControls,
114+
NgtsEnvironment,
115+
],
116+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
117+
})
118+
class DefaultMeshTransmissionMaterialStory {
119+
Math = Math;
120+
}
121+
122+
export default {
123+
title: 'Shaders/MeshTransmissionMaterial',
124+
decorators: makeDecorators(),
125+
};
126+
127+
const canvasOptions = makeCanvasOptions({ camera: { fov: 25, position: [15, 0, 15] } });
128+
129+
export const Default = makeStoryFunction(DefaultMeshTransmissionMaterialStory, canvasOptions);

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
},
1414
"private": true,
1515
"devDependencies": {
16-
"@analogjs/platform": "^0.2.1",
17-
"@analogjs/vite-plugin-angular": "^0.2.1",
16+
"@analogjs/platform": "^0.2.2",
17+
"@analogjs/vite-plugin-angular": "^0.2.2",
1818
"@angular-devkit/build-angular": "16.2.1",
1919
"@angular-devkit/core": "16.2.1",
2020
"@angular-devkit/schematics": "16.2.1",
@@ -24,20 +24,20 @@
2424
"@angular/cli": "~16.2.1",
2525
"@angular/compiler-cli": "16.2.3",
2626
"@angular/language-service": "16.2.3",
27-
"@nx/angular": "16.8.0",
28-
"@nx/devkit": "16.8.0",
29-
"@nx/eslint-plugin": "16.8.0",
30-
"@nx/jest": "16.8.0",
31-
"@nx/js": "16.8.0",
32-
"@nx/linter": "16.8.0",
33-
"@nx/plugin": "16.8.0",
34-
"@nx/storybook": "16.8.0",
35-
"@nx/vite": "16.8.0",
36-
"@nx/web": "16.8.0",
37-
"@nx/workspace": "16.8.0",
27+
"@nx/angular": "16.8.1",
28+
"@nx/devkit": "16.8.1",
29+
"@nx/eslint-plugin": "16.8.1",
30+
"@nx/jest": "16.8.1",
31+
"@nx/js": "16.8.1",
32+
"@nx/linter": "16.8.1",
33+
"@nx/plugin": "16.8.1",
34+
"@nx/storybook": "16.8.1",
35+
"@nx/vite": "16.8.1",
36+
"@nx/web": "16.8.1",
37+
"@nx/workspace": "16.8.1",
3838
"@phenomnomnominal/tsquery": "^6.1.3",
3939
"@release-it/bumper": "^5.1.0",
40-
"@release-it/conventional-changelog": "^7.0.0",
40+
"@release-it/conventional-changelog": "^7.0.1",
4141
"@schematics/angular": "16.2.1",
4242
"@storybook/addon-essentials": "7.4.0",
4343
"@storybook/addon-interactions": "7.4.0",
@@ -50,12 +50,12 @@
5050
"@storybook/theming": "^7.4.0",
5151
"@swc-node/register": "~1.6.7",
5252
"@swc/cli": "~0.1.62",
53-
"@swc/core": "~1.3.82",
53+
"@swc/core": "~1.3.83",
5454
"@types/jest": "^29.5.4",
5555
"@types/node": "20.5.9",
5656
"@types/three": "^0.155.1",
57-
"@typescript-eslint/eslint-plugin": "6.5.0",
58-
"@typescript-eslint/parser": "6.5.0",
57+
"@typescript-eslint/eslint-plugin": "6.6.0",
58+
"@typescript-eslint/parser": "6.6.0",
5959
"autoprefixer": "^10.4.15",
6060
"dotenv-cli": "^7.3.0",
6161
"enquirer": "^2.4.1",
@@ -67,9 +67,9 @@
6767
"jest-environment-jsdom": "^29.6.4",
6868
"jest-preset-angular": "~13.1.1",
6969
"jsdom": "^22.1.0",
70-
"ng-packagr": "16.2.2",
70+
"ng-packagr": "16.2.3",
7171
"ngx-resize": "^2.0.0",
72-
"nx": "16.8.0",
72+
"nx": "16.8.1",
7373
"postcss": "^8.4.29",
7474
"postcss-import": "~15.1.0",
7575
"postcss-preset-env": "~9.1.3",
@@ -90,8 +90,8 @@
9090
"vitest": "^0.34.3"
9191
},
9292
"dependencies": {
93-
"@analogjs/content": "^0.2.1",
94-
"@analogjs/router": "^0.2.1",
93+
"@analogjs/content": "^0.2.2",
94+
"@analogjs/router": "^0.2.2",
9595
"@angular/animations": "16.2.3",
9696
"@angular/common": "16.2.3",
9797
"@angular/compiler": "16.2.3",
@@ -102,15 +102,15 @@
102102
"@angular/platform-server": "16.2.3",
103103
"@angular/router": "16.2.3",
104104
"@pmndrs/cannon-worker-api": "^2.4.0",
105-
"@swc/helpers": "~0.5.1",
105+
"@swc/helpers": "~0.5.2",
106106
"cannon-es": "^0.20.0",
107107
"cannon-es-debugger": "^1.0.0",
108108
"front-matter": "^4.0.2",
109109
"gsap": "^3.12.2",
110110
"maath": "^0.7.0",
111111
"marked": "^7.0.5",
112-
"marked-gfm-heading-id": "^3.0.6",
113-
"marked-highlight": "^2.0.4",
112+
"marked-gfm-heading-id": "^3.0.7",
113+
"marked-highlight": "^2.0.5",
114114
"mermaid": "^10.4.0",
115115
"meshline": "^3.1.6",
116116
"nice-color-palettes": "^3.0.0",
@@ -119,8 +119,8 @@
119119
"react-dom": "^18.2.0",
120120
"rxjs": "~7.8.1",
121121
"stats-gl": "^1.0.5",
122-
"three-mesh-bvh": "^0.6.6",
123-
"three-stdlib": "^2.25.0",
122+
"three-mesh-bvh": "^0.6.7",
123+
"three-stdlib": "^2.25.1",
124124
"troika-three-text": "^0.47.2",
125125
"tslib": "^2.6.2",
126126
"zone.js": "~0.13.1"

0 commit comments

Comments
 (0)