|
| 1 | +import { CUSTOM_ELEMENTS_SCHEMA, Component, Input, signal } from '@angular/core'; |
| 2 | +import { Meta } from '@storybook/angular'; |
| 3 | +import { NgtArgs, injectBeforeRender } from 'angular-three'; |
| 4 | +import { NgtsSky } from 'angular-three-soba/staging'; |
| 5 | +import { makeDecorators, makeStoryObject, number } from '../setup-canvas'; |
| 6 | + |
| 7 | +@Component({ |
| 8 | + standalone: true, |
| 9 | + template: ` |
| 10 | + <ngts-sky |
| 11 | + [distance]="3000" |
| 12 | + [turbidity]="turbidity" |
| 13 | + [rayleigh]="rayleigh" |
| 14 | + [mieCoefficient]="mieCoefficient" |
| 15 | + [mieDirectionalG]="mieDirectionalG" |
| 16 | + [inclination]="inclination()" |
| 17 | + [azimuth]="azimuth" |
| 18 | + /> |
| 19 | + <ngt-mesh [rotation]="[Math.PI / 2, 0, 0]"> |
| 20 | + <ngt-plane-geometry *args="[100, 100, 4, 4]" /> |
| 21 | + <ngt-mesh-basic-material color="black" [wireframe]="true" /> |
| 22 | + </ngt-mesh> |
| 23 | + <ngt-axes-helper /> |
| 24 | + `, |
| 25 | + imports: [NgtsSky, NgtArgs], |
| 26 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 27 | +}) |
| 28 | +class RotationSkyStory { |
| 29 | + readonly Math = Math; |
| 30 | + @Input() turbidity = 8; |
| 31 | + @Input() rayleigh = 6; |
| 32 | + @Input() mieCoefficient = 0.005; |
| 33 | + @Input() mieDirectionalG = 0.8; |
| 34 | + @Input() azimuth = 0.25; |
| 35 | + |
| 36 | + readonly inclination = signal(0); |
| 37 | + |
| 38 | + constructor() { |
| 39 | + injectBeforeRender(() => { |
| 40 | + this.inclination.update((prev) => prev + 0.0015); |
| 41 | + }); |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +@Component({ |
| 46 | + standalone: true, |
| 47 | + template: ` |
| 48 | + <ngts-sky |
| 49 | + [distance]="3000" |
| 50 | + [turbidity]="turbidity" |
| 51 | + [rayleigh]="rayleigh" |
| 52 | + [mieCoefficient]="mieCoefficient" |
| 53 | + [mieDirectionalG]="mieDirectionalG" |
| 54 | + [inclination]="inclination" |
| 55 | + [azimuth]="azimuth" |
| 56 | + /> |
| 57 | + <ngt-mesh [rotation]="[Math.PI / 2, 0, 0]"> |
| 58 | + <ngt-plane-geometry *args="[100, 100, 4, 4]" /> |
| 59 | + <ngt-mesh-basic-material color="black" [wireframe]="true" /> |
| 60 | + </ngt-mesh> |
| 61 | + <ngt-axes-helper /> |
| 62 | + `, |
| 63 | + imports: [NgtsSky, NgtArgs], |
| 64 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 65 | +}) |
| 66 | +class CustomAnglesSkyStory { |
| 67 | + readonly Math = Math; |
| 68 | + @Input() turbidity = 8; |
| 69 | + @Input() rayleigh = 6; |
| 70 | + @Input() mieCoefficient = 0.005; |
| 71 | + @Input() mieDirectionalG = 0.8; |
| 72 | + @Input() inclination = 0.49; |
| 73 | + @Input() azimuth = 0.25; |
| 74 | +} |
| 75 | + |
| 76 | +@Component({ |
| 77 | + standalone: true, |
| 78 | + template: ` |
| 79 | + <ngts-sky |
| 80 | + [turbidity]="turbidity" |
| 81 | + [rayleigh]="rayleigh" |
| 82 | + [mieCoefficient]="mieCoefficient" |
| 83 | + [mieDirectionalG]="mieDirectionalG" |
| 84 | + [sunPosition]="[sunPositionX, sunPositionY, sunPositionZ]" |
| 85 | + /> |
| 86 | + <ngt-mesh [rotation]="[Math.PI / 2, 0, 0]"> |
| 87 | + <ngt-plane-geometry *args="[100, 100, 4, 4]" /> |
| 88 | + <ngt-mesh-basic-material color="black" [wireframe]="true" /> |
| 89 | + </ngt-mesh> |
| 90 | + <ngt-axes-helper /> |
| 91 | + `, |
| 92 | + imports: [NgtsSky, NgtArgs], |
| 93 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 94 | +}) |
| 95 | +class DefaultSkyStory { |
| 96 | + readonly Math = Math; |
| 97 | + @Input() turbidity = 8; |
| 98 | + @Input() rayleigh = 6; |
| 99 | + @Input() mieCoefficient = 0.005; |
| 100 | + @Input() mieDirectionalG = 0.8; |
| 101 | + @Input() sunPositionX = 1; |
| 102 | + @Input() sunPositionY = 0; |
| 103 | + @Input() sunPositionZ = 0; |
| 104 | +} |
| 105 | + |
| 106 | +export default { |
| 107 | + title: 'Staging/Sky', |
| 108 | + decorators: makeDecorators(), |
| 109 | +} as Meta; |
| 110 | + |
| 111 | +export const Default = makeStoryObject(DefaultSkyStory, { |
| 112 | + argsOptions: { |
| 113 | + turbidity: number(8, { min: 0, max: 10, step: 0.1, range: true }), |
| 114 | + rayleigh: number(6, { min: 0, max: 10, step: 0.1, range: true }), |
| 115 | + mieCoefficient: number(0.005, { min: 0, max: 0.1, step: 0.001, range: true }), |
| 116 | + mieDirectionalG: number(0.8, { min: 0, max: 1, step: 0.01, range: true }), |
| 117 | + sunPositionX: number(1), |
| 118 | + sunPositionY: number(0), |
| 119 | + sunPositionZ: number(0), |
| 120 | + }, |
| 121 | +}); |
| 122 | + |
| 123 | +export const CustomAngles = makeStoryObject(CustomAnglesSkyStory, { |
| 124 | + argsOptions: { |
| 125 | + turbidity: number(8, { min: 0, max: 10, step: 0.1, range: true }), |
| 126 | + rayleigh: number(6, { min: 0, max: 10, step: 0.1, range: true }), |
| 127 | + mieCoefficient: number(0.005, { min: 0, max: 0.1, step: 0.001, range: true }), |
| 128 | + mieDirectionalG: number(0.8, { min: 0, max: 1, step: 0.01, range: true }), |
| 129 | + inclination: number(0.49, { min: 0, max: 1, step: 0.01, range: true }), |
| 130 | + azimuth: number(0.25, { min: 0, max: 1, step: 0.01, range: true }), |
| 131 | + }, |
| 132 | +}); |
| 133 | + |
| 134 | +export const Rotation = makeStoryObject(RotationSkyStory, { |
| 135 | + argsOptions: { |
| 136 | + turbidity: number(8, { min: 0, max: 10, step: 0.1, range: true }), |
| 137 | + rayleigh: number(6, { min: 0, max: 10, step: 0.1, range: true }), |
| 138 | + mieCoefficient: number(0.005, { min: 0, max: 0.1, step: 0.001, range: true }), |
| 139 | + mieDirectionalG: number(0.8, { min: 0, max: 1, step: 0.01, range: true }), |
| 140 | + azimuth: number(0.25, { min: 0, max: 1, step: 0.01, range: true }), |
| 141 | + }, |
| 142 | +}); |
0 commit comments