Skip to content

Commit

Permalink
Merge pull request #7 from vimcaw/shader-editor
Browse files Browse the repository at this point in the history
  • Loading branch information
vimcaw authored Apr 25, 2023
2 parents f6620bf + 848b599 commit 97ab5a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-actors-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'core': patch
---

fix: cannot check the debug flag option
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Object3D } from 'three';
import { Checkbox } from 'antd';
import { O } from 'ts-toolbelt';
import { observerLayer } from '../../store/threeJsData';
import { isObject3DWithOnBeforeRenderFlag } from '../types';
import { Object3DWithOnBeforeRenderFlag } from '../types';

export default function BooleanProperty<T extends Object3D>({
object,
Expand Down Expand Up @@ -37,9 +37,9 @@ export function CustomBooleanProperty<T extends Object3D>({
<Checkbox
checked={object[propName]}
onChange={e => {
const node = observerLayer.findNode(object.uuid);
const node = observerLayer.findNode(object.uuid) as Object3DWithOnBeforeRenderFlag;

if (node && isObject3DWithOnBeforeRenderFlag(node)) {
if (node) {
if (!node[propName]) {
node.onBeforeRenderCopy = node.onBeforeRender;
node.onBeforeRender = () => {
Expand Down
12 changes: 1 addition & 11 deletions packages/core/src/PropertiesPanel/types.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import type { Object3D } from 'three';

export type Object3DWithOnBeforeRenderFlag = Object3D & {
onBeforeRenderFlag: boolean;
onBeforeRenderFlag?: boolean;
onBeforeRenderCopy?: Object3D['onBeforeRender'];
};

export function isObject3DWithOnBeforeRenderFlag(
object: unknown
): object is Object3DWithOnBeforeRenderFlag {
return (
typeof object === 'object' &&
object !== null &&
(object as Object3DWithOnBeforeRenderFlag).onBeforeRenderFlag !== undefined
);
}

0 comments on commit 97ab5a6

Please sign in to comment.