angular-three-soba 1.3.2 → 1.5.0

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.
Files changed (57) hide show
  1. package/abstractions/README.md +3 -0
  2. package/abstractions/index.d.ts +10 -0
  3. package/abstractions/lib/billboard/billboard.d.ts +14 -0
  4. package/abstractions/lib/catmull-rom-line/catmull-rom-line.d.ts +15 -0
  5. package/abstractions/lib/cubic-bezier-line/cubic-bezier-line.d.ts +15 -0
  6. package/abstractions/lib/gizmo-helper/gizmo-helper.d.ts +41 -0
  7. package/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.d.ts +12 -0
  8. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.d.ts +16 -0
  9. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.d.ts +24 -0
  10. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.d.ts +14 -0
  11. package/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.d.ts +15 -0
  12. package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.d.ts +28 -0
  13. package/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.d.ts +21 -0
  14. package/abstractions/lib/line/line-input.d.ts +19 -0
  15. package/abstractions/lib/line/line.d.ts +21 -0
  16. package/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.d.ts +19 -0
  17. package/abstractions/lib/text/text.d.ts +21 -0
  18. package/abstractions/lib/text-3d/text-3d.d.ts +39 -0
  19. package/esm2020/abstractions/angular-three-soba-abstractions.mjs +5 -0
  20. package/esm2020/abstractions/index.mjs +11 -0
  21. package/esm2020/abstractions/lib/billboard/billboard.mjs +73 -0
  22. package/esm2020/abstractions/lib/catmull-rom-line/catmull-rom-line.mjs +119 -0
  23. package/esm2020/abstractions/lib/cubic-bezier-line/cubic-bezier-line.mjs +98 -0
  24. package/esm2020/abstractions/lib/gizmo-helper/gizmo-helper.mjs +206 -0
  25. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/constants.mjs +31 -0
  26. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-edge.mjs +91 -0
  27. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-face.mjs +182 -0
  28. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube-inputs.mjs +45 -0
  29. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewcube/gizmo-viewcube.mjs +133 -0
  30. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport-axis.mjs +193 -0
  31. package/esm2020/abstractions/lib/gizmo-helper/gizmo-viewport/gizmo-viewport.mjs +266 -0
  32. package/esm2020/abstractions/lib/line/line-input.mjs +75 -0
  33. package/esm2020/abstractions/lib/line/line.mjs +147 -0
  34. package/esm2020/abstractions/lib/quadratic-bezier-line/quadratic-bezier-line.mjs +127 -0
  35. package/esm2020/abstractions/lib/text/text.mjs +110 -0
  36. package/esm2020/abstractions/lib/text-3d/text-3d.mjs +144 -0
  37. package/esm2020/cameras/lib/orthographic-camera/orthographic-camera.mjs +5 -5
  38. package/esm2020/staging/index.mjs +3 -1
  39. package/esm2020/staging/lib/camera-shake/camera-shake.mjs +121 -0
  40. package/esm2020/staging/lib/cloud/cloud.mjs +159 -0
  41. package/fesm2015/angular-three-soba-abstractions.mjs +1965 -0
  42. package/fesm2015/angular-three-soba-abstractions.mjs.map +1 -0
  43. package/fesm2015/angular-three-soba-cameras.mjs +4 -4
  44. package/fesm2015/angular-three-soba-cameras.mjs.map +1 -1
  45. package/fesm2015/angular-three-soba-staging.mjs +274 -4
  46. package/fesm2015/angular-three-soba-staging.mjs.map +1 -1
  47. package/fesm2020/angular-three-soba-abstractions.mjs +1962 -0
  48. package/fesm2020/angular-three-soba-abstractions.mjs.map +1 -0
  49. package/fesm2020/angular-three-soba-cameras.mjs +4 -4
  50. package/fesm2020/angular-three-soba-cameras.mjs.map +1 -1
  51. package/fesm2020/angular-three-soba-staging.mjs +274 -4
  52. package/fesm2020/angular-three-soba-staging.mjs.map +1 -1
  53. package/package.json +11 -3
  54. package/plugin/package.json +1 -1
  55. package/staging/index.d.ts +2 -0
  56. package/staging/lib/camera-shake/camera-shake.d.ts +28 -0
  57. package/staging/lib/cloud/cloud.d.ts +23 -0
@@ -4,9 +4,11 @@ import { extend, NgtStore, getLocalState, NgtRxStore, injectNgtRef, NgtArgs, Ngt
4
4
  import { shaderMaterial } from 'angular-three-soba/shaders';
5
5
  import { Subject, combineLatest, switchMap, isObservable, of, debounceTime, map, takeUntil, startWith, withLatestFrom } from 'rxjs';
6
6
  import * as THREE from 'three';
7
- import { Group, Mesh, PlaneGeometry, DirectionalLight, OrthographicCamera, Vector2, Box3, Vector3, Sphere, MeshBasicMaterial, CubeTextureLoader, CubeReflectionMapping, EquirectangularReflectionMapping, sRGBEncoding, LinearEncoding, CubeCamera, HalfFloatType, Points, BufferGeometry, BufferAttribute, Vector4, Color, MathUtils, AmbientLight, SpotLight, PointLight, Spherical, AdditiveBlending } from 'three';
8
- import { NgIf, NgTemplateOutlet } from '@angular/common';
9
- import { HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky } from 'three-stdlib';
7
+ import { Group, Mesh, PlaneGeometry, DirectionalLight, OrthographicCamera, Vector2, Box3, Vector3, Sphere, MeshStandardMaterial, MeshBasicMaterial, CubeTextureLoader, CubeReflectionMapping, EquirectangularReflectionMapping, sRGBEncoding, LinearEncoding, CubeCamera, HalfFloatType, Points, BufferGeometry, BufferAttribute, Vector4, Color, MathUtils, AmbientLight, SpotLight, PointLight, Spherical, AdditiveBlending } from 'three';
8
+ import { SimplexNoise, HorizontalBlurShader, VerticalBlurShader, RGBELoader, GroundProjectedEnv, Sky } from 'three-stdlib';
9
+ import { NgFor, NgIf, NgTemplateOutlet } from '@angular/common';
10
+ import { NgtsBillboard } from 'angular-three-soba/abstractions';
11
+ import { injectNgtsTextureLoader } from 'angular-three-soba/loaders';
10
12
 
11
13
  function isLight(object) {
12
14
  return object.isLight;
@@ -854,6 +856,122 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
854
856
  type: Output
855
857
  }] } });
856
858
 
859
+ class NgtsCameraShake extends NgtRxStore {
860
+ set intensity(intensity) {
861
+ this.set({ intensity });
862
+ }
863
+ set decay(decay) {
864
+ this.set({ decay });
865
+ }
866
+ set decayRate(decayRate) {
867
+ this.set({ decayRate });
868
+ }
869
+ set maxYaw(maxYaw) {
870
+ this.set({ maxYaw });
871
+ }
872
+ set maxPitch(maxPitch) {
873
+ this.set({ maxPitch });
874
+ }
875
+ set maxRoll(maxRoll) {
876
+ this.set({ maxRoll });
877
+ }
878
+ set yawFrequency(yawFrequency) {
879
+ this.set({ yawFrequency });
880
+ }
881
+ set pitchFrequency(pitchFrequency) {
882
+ this.set({ pitchFrequency });
883
+ }
884
+ set rollFrequency(rollFrequency) {
885
+ this.set({ rollFrequency });
886
+ }
887
+ initialize() {
888
+ super.initialize();
889
+ this.set({
890
+ intensity: 1,
891
+ decayRate: 0.65,
892
+ maxYaw: 0.1,
893
+ maxPitch: 0.1,
894
+ maxRoll: 0.1,
895
+ yawFrequency: 0.1,
896
+ pitchFrequency: 0.1,
897
+ rollFrequency: 0.1,
898
+ });
899
+ }
900
+ constructor() {
901
+ super();
902
+ this.store = inject(NgtStore);
903
+ this.initialRotation = this.store.get('camera').rotation.clone();
904
+ this.yawNoise = new SimplexNoise();
905
+ this.pitchNoise = new SimplexNoise();
906
+ this.rollNoise = new SimplexNoise();
907
+ injectBeforeRender(({ clock, delta, camera }) => {
908
+ const { intensity, maxYaw, maxPitch, maxRoll, yawFrequency, pitchFrequency, rollFrequency, decay, decayRate, } = this.get();
909
+ const shake = Math.pow(intensity, 2);
910
+ const yaw = maxYaw * shake * this.yawNoise.noise(clock.elapsedTime * yawFrequency, 1);
911
+ const pitch = maxPitch * shake * this.pitchNoise.noise(clock.elapsedTime * pitchFrequency, 1);
912
+ const roll = maxRoll * shake * this.rollNoise.noise(clock.elapsedTime * rollFrequency, 1);
913
+ camera.rotation.set(this.initialRotation.x + pitch, this.initialRotation.y + yaw, this.initialRotation.z + roll);
914
+ if (decay && intensity > 0) {
915
+ this.set({ intensity: intensity - decayRate * delta });
916
+ this.constraintIntensity();
917
+ }
918
+ });
919
+ }
920
+ ngOnInit() {
921
+ this.setChangeEvent();
922
+ }
923
+ setChangeEvent() {
924
+ this.effect(combineLatest([this.store.select('camera'), this.store.select('controls')]), ([camera, controls]) => {
925
+ if (controls) {
926
+ const callback = () => void (this.initialRotation = camera.rotation.clone());
927
+ controls.addEventListener('change', callback);
928
+ callback();
929
+ return () => void controls.removeEventListener('change', callback);
930
+ }
931
+ });
932
+ }
933
+ getIntensity() {
934
+ return this.get('intensity');
935
+ }
936
+ setIntensity(intensity) {
937
+ this.set({ intensity });
938
+ this.constraintIntensity();
939
+ }
940
+ constraintIntensity() {
941
+ const intensity = this.get('intensity');
942
+ if (intensity < 0 || intensity > 1) {
943
+ this.set({ intensity: intensity < 0 ? 0 : 1 });
944
+ }
945
+ }
946
+ }
947
+ NgtsCameraShake.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsCameraShake, deps: [], target: i0.ɵɵFactoryTarget.Directive });
948
+ NgtsCameraShake.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.1.3", type: NgtsCameraShake, isStandalone: true, selector: "ngts-camera-shake", inputs: { intensity: "intensity", decay: "decay", decayRate: "decayRate", maxYaw: "maxYaw", maxPitch: "maxPitch", maxRoll: "maxRoll", yawFrequency: "yawFrequency", pitchFrequency: "pitchFrequency", rollFrequency: "rollFrequency" }, usesInheritance: true, ngImport: i0 });
949
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsCameraShake, decorators: [{
950
+ type: Directive,
951
+ args: [{
952
+ selector: 'ngts-camera-shake',
953
+ standalone: true,
954
+ }]
955
+ }], ctorParameters: function () { return []; }, propDecorators: { intensity: [{
956
+ type: Input
957
+ }], decay: [{
958
+ type: Input
959
+ }], decayRate: [{
960
+ type: Input
961
+ }], maxYaw: [{
962
+ type: Input
963
+ }], maxPitch: [{
964
+ type: Input
965
+ }], maxRoll: [{
966
+ type: Input
967
+ }], yawFrequency: [{
968
+ type: Input
969
+ }], pitchFrequency: [{
970
+ type: Input
971
+ }], rollFrequency: [{
972
+ type: Input
973
+ }] } });
974
+
857
975
  extend({ Group });
858
976
  class NgtsCenter extends NgtRxStore {
859
977
  constructor() {
@@ -991,6 +1109,158 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
991
1109
  type: Output
992
1110
  }] } });
993
1111
 
1112
+ const CLOUD_URL = 'https://rawcdn.githack.com/pmndrs/drei-assets/9225a9f1fbd449d9411125c2f419b843d0308c9f/cloud.png';
1113
+ extend({ Group, Mesh, PlaneGeometry, MeshStandardMaterial });
1114
+ class NgtsCloud extends NgtRxStore {
1115
+ constructor() {
1116
+ super(...arguments);
1117
+ this.store = inject(NgtStore);
1118
+ this.encoding = this.store.get('gl', 'outputEncoding');
1119
+ this.groupRef = injectNgtRef();
1120
+ this.clouds$ = this.select('clouds');
1121
+ this.cloudTexture$ = injectNgtsTextureLoader(this.select('texture'));
1122
+ }
1123
+ set opacity(opacity) {
1124
+ this.set({ opacity });
1125
+ }
1126
+ set speed(speed) {
1127
+ this.set({ speed });
1128
+ }
1129
+ set width(width) {
1130
+ this.set({ width });
1131
+ }
1132
+ set depth(depth) {
1133
+ this.set({ depth });
1134
+ }
1135
+ set segments(segments) {
1136
+ this.set({ segments });
1137
+ }
1138
+ set texture(texture) {
1139
+ this.set({ texture });
1140
+ }
1141
+ set color(color) {
1142
+ this.set({ color });
1143
+ }
1144
+ set depthTest(depthTest) {
1145
+ this.set({ depthTest });
1146
+ }
1147
+ initialize() {
1148
+ super.initialize();
1149
+ this.set({
1150
+ opacity: 0.5,
1151
+ speed: 0.4,
1152
+ width: 10,
1153
+ depth: 1.5,
1154
+ segments: 20,
1155
+ texture: CLOUD_URL,
1156
+ color: '#ffffff',
1157
+ depthTest: true,
1158
+ });
1159
+ this.connect('clouds', this.select(['width', 'segments', 'speed'], ({ width, segments, speed }) => {
1160
+ return [...new Array(segments)].map((_, index) => ({
1161
+ x: width / 2 - Math.random() * width,
1162
+ y: width / 2 - Math.random() * width,
1163
+ scale: 0.4 + Math.sin(((index + 1) / segments) * Math.PI) * ((0.2 + Math.random()) * 10),
1164
+ density: Math.max(0.2, Math.random()),
1165
+ rotation: Math.max(0.002, 0.005 * Math.random()) * speed,
1166
+ }));
1167
+ }));
1168
+ }
1169
+ onBeforeRender({ state, object }) {
1170
+ const clouds = this.get('clouds');
1171
+ object.children.forEach((cloud, index) => {
1172
+ cloud.children[0].rotation.z += clouds[index].rotation;
1173
+ cloud.children[0].scale.setScalar(clouds[index].scale + (((1 + Math.sin(state.clock.getElapsedTime() / 10)) / 2) * index) / 10);
1174
+ });
1175
+ }
1176
+ }
1177
+ NgtsCloud.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsCloud, deps: null, target: i0.ɵɵFactoryTarget.Component });
1178
+ NgtsCloud.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.1.3", type: NgtsCloud, isStandalone: true, selector: "ngts-cloud", inputs: { groupRef: "groupRef", opacity: "opacity", speed: "speed", width: "width", depth: "depth", segments: "segments", texture: "texture", color: "color", depthTest: "depthTest" }, usesInheritance: true, ngImport: i0, template: `
1179
+ <ngt-group ngtCompound [ref]="groupRef">
1180
+ <ngt-group
1181
+ [position]="[0, 0, (get('segments') / 2) * get('depth')]"
1182
+ (beforeRender)="onBeforeRender($any($event))"
1183
+ >
1184
+ <ngts-billboard
1185
+ *ngFor="let cloud of clouds$ | ngtPush : []; let i = index"
1186
+ [position]="[cloud.x, cloud.y, -i * get('depth')]"
1187
+ >
1188
+ <ngt-mesh [scale]="cloud.scale" [rotation]="[0, 0, 0]">
1189
+ <ngt-plane-geometry />
1190
+ <!-- we use ngIf here for texture because by the time ngt-value is initialized -->
1191
+ <!-- [map] has not been resolved yet. we ngIf it so that texture is available before -->
1192
+ <ngt-mesh-standard-material
1193
+ *ngIf="cloudTexture$ | ngtPush as cloudTexture"
1194
+ [transparent]="true"
1195
+ [map]="cloudTexture"
1196
+ [depthTest]="get('depthTest')"
1197
+ [opacity]="(cloud.scale / 6) * cloud.density * get('opacity')"
1198
+ [color]="get('color')"
1199
+ >
1200
+ <ngt-value [rawValue]="encoding" attach="map.encoding" />
1201
+ </ngt-mesh-standard-material>
1202
+ </ngt-mesh>
1203
+ </ngts-billboard>
1204
+ </ngt-group>
1205
+ </ngt-group>
1206
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: NgtPush, name: "ngtPush" }, { kind: "component", type: NgtsBillboard, selector: "ngts-billboard", inputs: ["billboardRef", "follow", "lockX", "lockY", "lockZ"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
1207
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImport: i0, type: NgtsCloud, decorators: [{
1208
+ type: Component,
1209
+ args: [{
1210
+ selector: 'ngts-cloud',
1211
+ standalone: true,
1212
+ template: `
1213
+ <ngt-group ngtCompound [ref]="groupRef">
1214
+ <ngt-group
1215
+ [position]="[0, 0, (get('segments') / 2) * get('depth')]"
1216
+ (beforeRender)="onBeforeRender($any($event))"
1217
+ >
1218
+ <ngts-billboard
1219
+ *ngFor="let cloud of clouds$ | ngtPush : []; let i = index"
1220
+ [position]="[cloud.x, cloud.y, -i * get('depth')]"
1221
+ >
1222
+ <ngt-mesh [scale]="cloud.scale" [rotation]="[0, 0, 0]">
1223
+ <ngt-plane-geometry />
1224
+ <!-- we use ngIf here for texture because by the time ngt-value is initialized -->
1225
+ <!-- [map] has not been resolved yet. we ngIf it so that texture is available before -->
1226
+ <ngt-mesh-standard-material
1227
+ *ngIf="cloudTexture$ | ngtPush as cloudTexture"
1228
+ [transparent]="true"
1229
+ [map]="cloudTexture"
1230
+ [depthTest]="get('depthTest')"
1231
+ [opacity]="(cloud.scale / 6) * cloud.density * get('opacity')"
1232
+ [color]="get('color')"
1233
+ >
1234
+ <ngt-value [rawValue]="encoding" attach="map.encoding" />
1235
+ </ngt-mesh-standard-material>
1236
+ </ngt-mesh>
1237
+ </ngts-billboard>
1238
+ </ngt-group>
1239
+ </ngt-group>
1240
+ `,
1241
+ imports: [NgFor, NgtPush, NgtsBillboard, NgIf],
1242
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
1243
+ }]
1244
+ }], propDecorators: { groupRef: [{
1245
+ type: Input
1246
+ }], opacity: [{
1247
+ type: Input
1248
+ }], speed: [{
1249
+ type: Input
1250
+ }], width: [{
1251
+ type: Input
1252
+ }], depth: [{
1253
+ type: Input
1254
+ }], segments: [{
1255
+ type: Input
1256
+ }], texture: [{
1257
+ type: Input
1258
+ }], color: [{
1259
+ type: Input
1260
+ }], depthTest: [{
1261
+ type: Input
1262
+ }] } });
1263
+
994
1264
  extend({ Group, Mesh, MeshBasicMaterial, OrthographicCamera });
995
1265
  class NgtsContactShadows extends NgtRxStore {
996
1266
  set opacity(opacity) {
@@ -2648,5 +2918,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.3", ngImpor
2648
2918
  * Generated bundle index. Do not edit.
2649
2919
  */
2650
2920
 
2651
- export { NGTS_BOUNDS_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCenter, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
2921
+ export { NGTS_BOUNDS_API, NgtsAccumulativeShadows, NgtsBounds, NgtsCameraShake, NgtsCenter, NgtsCloud, NgtsContactShadows, NgtsEnvironment, NgtsEnvironmentContent, NgtsFloat, NgtsRandomizedLights, NgtsSky, NgtsSparkles, NgtsStage, NgtsStageRefit, NgtsStars, calcPosFromAngles, ngtsEnvironmentPresetsObj };
2652
2922
  //# sourceMappingURL=angular-three-soba-staging.mjs.map