|
| 1 | +import { ChangeDetectionStrategy, Component, CUSTOM_ELEMENTS_SCHEMA, input } from '@angular/core'; |
| 2 | +import { Meta } from '@storybook/angular'; |
| 3 | +import { NgtArgs } from 'angular-three'; |
| 4 | +import { NgtsBillboard, NgtsText } from 'angular-three-soba/abstractions'; |
| 5 | +import { NgtsOrbitControls } from 'angular-three-soba/controls'; |
| 6 | +import { makeDecorators, makeStoryObject } from '../setup-canvas'; |
| 7 | + |
| 8 | +@Component({ |
| 9 | + standalone: true, |
| 10 | + template: ` |
| 11 | + <ngts-billboard |
| 12 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [0.5, 2.05, 0.5] }" |
| 13 | + > |
| 14 | + <ngts-text |
| 15 | + text="hello" |
| 16 | + [options]="{ fontSize: 1, outlineWidth: '5%', outlineColor: '#000000', outlineOpacity: 1 }" |
| 17 | + /> |
| 18 | + </ngts-billboard> |
| 19 | + <ngt-mesh [position]="[0.5, 1, 0.5]"> |
| 20 | + <ngt-box-geometry /> |
| 21 | + <ngt-mesh-standard-material color="red" /> |
| 22 | + </ngt-mesh> |
| 23 | + <ngt-group [position]="[-2.5, -3, -1]"> |
| 24 | + <ngts-billboard |
| 25 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [0, 1.05, 0] }" |
| 26 | + > |
| 27 | + <ngts-text |
| 28 | + text="cone" |
| 29 | + [options]="{ fontSize: 1, outlineWidth: '5%', outlineColor: '#000000', outlineOpacity: 1 }" |
| 30 | + /> |
| 31 | + </ngts-billboard> |
| 32 | + <ngt-mesh> |
| 33 | + <ngt-cone-geometry /> |
| 34 | + <ngt-mesh-standard-material color="green" /> |
| 35 | + </ngt-mesh> |
| 36 | + </ngt-group> |
| 37 | +
|
| 38 | + <ngts-billboard |
| 39 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [0, 0, -5] }" |
| 40 | + > |
| 41 | + <ngt-mesh> |
| 42 | + <ngt-plane-geometry /> |
| 43 | + <ngt-mesh-standard-material color="#000066" /> |
| 44 | + </ngt-mesh> |
| 45 | + </ngts-billboard> |
| 46 | +
|
| 47 | + <ngts-orbit-controls [options]="{ enablePan: true, zoomSpeed: 0.5 }" /> |
| 48 | + `, |
| 49 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 50 | + changeDetection: ChangeDetectionStrategy.OnPush, |
| 51 | + imports: [NgtsBillboard, NgtsText, NgtsOrbitControls], |
| 52 | +}) |
| 53 | +class TextBillboardStory { |
| 54 | + follow = input(true); |
| 55 | + lockX = input(false); |
| 56 | + lockY = input(false); |
| 57 | + lockZ = input(false); |
| 58 | +} |
| 59 | + |
| 60 | +@Component({ |
| 61 | + standalone: true, |
| 62 | + template: ` |
| 63 | + <ngts-billboard |
| 64 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [-4, -2, 0] }" |
| 65 | + > |
| 66 | + <ngt-mesh> |
| 67 | + <ngt-plane-geometry *args="[3, 2]" /> |
| 68 | + <ngt-value rawValue="red" attach="material.color" /> |
| 69 | + </ngt-mesh> |
| 70 | + </ngts-billboard> |
| 71 | +
|
| 72 | + <ngts-billboard |
| 73 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [-4, 2, 0] }" |
| 74 | + > |
| 75 | + <ngt-mesh> |
| 76 | + <ngt-plane-geometry *args="[3, 2]" /> |
| 77 | + <ngt-value rawValue="orange" attach="material.color" /> |
| 78 | + </ngt-mesh> |
| 79 | + </ngts-billboard> |
| 80 | +
|
| 81 | + <ngts-billboard |
| 82 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [0, 0, 0] }" |
| 83 | + > |
| 84 | + <ngt-mesh> |
| 85 | + <ngt-plane-geometry *args="[3, 2]" /> |
| 86 | + <ngt-value rawValue="green" attach="material.color" /> |
| 87 | + </ngt-mesh> |
| 88 | + </ngts-billboard> |
| 89 | +
|
| 90 | + <ngts-billboard |
| 91 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [4, -2, 0] }" |
| 92 | + > |
| 93 | + <ngt-mesh> |
| 94 | + <ngt-plane-geometry *args="[3, 2]" /> |
| 95 | + <ngt-value rawValue="blue" attach="material.color" /> |
| 96 | + </ngt-mesh> |
| 97 | + </ngts-billboard> |
| 98 | +
|
| 99 | + <ngts-billboard |
| 100 | + [options]="{ follow: follow(), lockZ: lockZ(), lockY: lockY(), lockX: lockX(), position: [4, 2, 0] }" |
| 101 | + > |
| 102 | + <ngt-mesh> |
| 103 | + <ngt-plane-geometry *args="[3, 2]" /> |
| 104 | + <ngt-value rawValue="yellow" attach="material.color" /> |
| 105 | + </ngt-mesh> |
| 106 | + </ngts-billboard> |
| 107 | +
|
| 108 | + <ngts-orbit-controls [options]="{ enablePan: true, zoomSpeed: 0.5 }" /> |
| 109 | + `, |
| 110 | + schemas: [CUSTOM_ELEMENTS_SCHEMA], |
| 111 | + changeDetection: ChangeDetectionStrategy.OnPush, |
| 112 | + imports: [NgtsBillboard, NgtsOrbitControls, NgtArgs], |
| 113 | +}) |
| 114 | +class DefaultBillboardStory { |
| 115 | + follow = input(true); |
| 116 | + lockX = input(false); |
| 117 | + lockY = input(false); |
| 118 | + lockZ = input(false); |
| 119 | +} |
| 120 | + |
| 121 | +export default { |
| 122 | + title: 'Abstractions/Billboard', |
| 123 | + decorators: makeDecorators(), |
| 124 | +} as Meta; |
| 125 | + |
| 126 | +export const Default = makeStoryObject(DefaultBillboardStory, { |
| 127 | + canvasOptions: { camera: { position: [0, 0, 10] }, controls: false }, |
| 128 | + argsOptions: { follow: true, lockX: false, lockY: false, lockZ: false }, |
| 129 | +}); |
| 130 | + |
| 131 | +export const Text = makeStoryObject(TextBillboardStory, { |
| 132 | + canvasOptions: { camera: { position: [0, 0, 10] }, controls: false }, |
| 133 | + argsOptions: { follow: true, lockX: false, lockY: false, lockZ: false }, |
| 134 | +}); |
0 commit comments