Skip to content

Commit 96892ad

Browse files
committed
fix(soba,core): controls now work
1 parent 6db540b commit 96892ad

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

libs/core/src/lib/renderer/renderer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ export class NgtRenderer2 implements Renderer2 {
334334
}
335335

336336
if (pRS[NgtRendererClassId.type] === 'platform' && cRS[NgtRendererClassId.type] === 'platform') {
337+
if (newChild[NGT_DOM_PARENT_FLAG] && newChild[NGT_DOM_PARENT_FLAG] instanceof HTMLElement) {
338+
return this.delegateRenderer.appendChild(newChild[NGT_DOM_PARENT_FLAG], newChild);
339+
}
340+
337341
if (pRS[NgtRendererClassId.parent] && !cRS[NgtRendererClassId.parent]) {
338342
return this.appendChild(pRS[NgtRendererClassId.parent], newChild);
339343
}

libs/soba/controls/src/lib/scroll-controls.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export class NgtsScrollControls {
181181
const onScroll = () => {
182182
// Prevent first scroll because it is indirectly caused by the one pixel offset
183183
if (!enabled || firstRun) return;
184+
184185
invalidate();
185186
current = el[horizontal ? 'scrollLeft' : 'scrollTop'];
186187
this.scroll = current / scrollThreshold;
@@ -286,7 +287,7 @@ export class NgtsCanvasScrollContent {
286287

287288
@Directive({
288289
selector: 'div[htmlScrollContent]',
289-
host: { style: 'position: absolute; top: 0; left: 0; will-change: transform;' },
290+
host: { style: 'position: absolute; top: 0; left: 0; will-change: transform;', 'data-html-scroll-content': '' },
290291
providers: [provideHTMLDomElement([NgtsScrollControls], (scrollControls) => scrollControls.fixed)],
291292
})
292293
export class NgtsHTMLScrollContent extends NgtHTML {

libs/soba/src/controls/scroll-controls.stories.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export default {
231231
export const Default = storyObject(DefaultScrollControlsStory, {
232232
camera: { zoom: 80 },
233233
orthographic: true,
234-
controls: false,
234+
controls: null,
235235
argsOptions: {
236236
options: {
237237
pages: 3, // Each page takes 100% of the height of the canvas
@@ -251,7 +251,7 @@ export const InsideAContainer = storyObject(DefaultScrollControlsStory, {
251251
`,
252252
camera: { zoom: 80 },
253253
orthographic: true,
254-
controls: false,
254+
controls: null,
255255
argsOptions: {
256256
options: {
257257
pages: 3, // Each page takes 100% of the height of the canvas
@@ -266,5 +266,5 @@ export const InsideAContainer = storyObject(DefaultScrollControlsStory, {
266266
export const Model = storyFunction(LittlestTokyoStory, {
267267
camera: { position: [0, 0, 10] },
268268
lights: false,
269-
controls: false,
269+
controls: null,
270270
});

libs/soba/src/gizmos/transform-controls.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { select, storyDecorators, storyFunction, storyObject } from '../setup-ca
77

88
@Component({
99
template: `
10-
<ngt-mesh #meshOne [position]="[-1, 0, 0]" (click)="selected.set(meshOne)">
10+
<ngt-mesh #meshOne [position]="[-1, 0, 0]" (click)="$event.stopPropagation(); selected.set(meshOne)">
1111
<ngt-box-geometry />
1212
<ngt-mesh-basic-material [wireframe]="selected() === meshOne" color="orange" />
1313
</ngt-mesh>
14-
<ngt-mesh #meshTwo [position]="[0, 0, 0]" (click)="selected.set(meshTwo)">
14+
<ngt-mesh #meshTwo [position]="[0, 0, 0]" (click)="$event.stopPropagation(); selected.set(meshTwo)">
1515
<ngt-box-geometry />
1616
<ngt-mesh-basic-material [wireframe]="selected() === meshTwo" color="green" />
1717
</ngt-mesh>

libs/soba/src/setup-canvas.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { extend, injectBeforeRender, NgtAnyRecord, NgtArgs, NgtCanvasOptions, re
2525
import { NgtsOrbitControls } from 'angular-three-soba/controls';
2626
import { NgtsLoader } from 'angular-three-soba/loaders';
2727
import { NgtCanvas, NgtCanvasContent, provideNgtRenderer } from 'angular-three/dom';
28-
import { mergeInputs } from 'ngxtension/inject-inputs';
2928
import * as THREE from 'three';
3029

3130
@Component({
@@ -124,8 +123,8 @@ export class StorybookSetup {
124123
loader = input(false);
125124

126125
/* canvas options */
127-
performance = input(defaultPerformanceOptions, { transform: mergeInputs(defaultPerformanceOptions) });
128-
camera = input(defaultCameraOptions, { transform: mergeInputs(defaultCameraOptions) });
126+
performance = input<NgtCanvasOptions['performance']>({});
127+
camera = input<NgtCanvasOptions['camera']>({});
129128
orthographic = input(false);
130129

131130
/* scene graph options */
@@ -149,7 +148,7 @@ type StoryOptions = {
149148
camera: NgtCanvasOptions['camera'];
150149
background: THREE.ColorRepresentation;
151150
orthographic: boolean;
152-
controls: boolean;
151+
controls: boolean | null;
153152
lights: boolean;
154153
};
155154

@@ -177,6 +176,10 @@ export function storyFunction(
177176
lights = defaultStoryOptions.lights,
178177
}: Partial<StoryOptions> = {},
179178
) {
179+
if (!orthographic) {
180+
camera = { ...defaultStoryOptions.camera, ...camera };
181+
}
182+
180183
return (args: Args) => ({
181184
props: {
182185
storyOptions: args || {},

0 commit comments

Comments
 (0)