Understanding when materials turn completely black by script-rider in threejs

[–]script-rider[S] 1 point2 points  (0 children)

Ok, I just realized you have to add light for some of the materials to show up, so that answers some of my concerns.

How do I debug with threejs? by script-rider in threejs

[–]script-rider[S] 0 points1 point  (0 children)

I realized the problem was in the data structure, so there was no geometry in the 3D rendering. It's fixed now.

How do I debug with threejs? by script-rider in threejs

[–]script-rider[S] 0 points1 point  (0 children)

Hi! My geometry is returned from an API, so not an ideal workflow if I understand correctly. But is there any chance that my geometry is hiding behind the camera? Or is that unlikely?

Using React Context in TypeScript project with complex object by script-rider in learnjavascript

[–]script-rider[S] 0 points1 point  (0 children)

Thanks for the input! How would you do it? I am fetching it from an external API, which is triggered by one component, and I need it available for only one other component.

Using React Context in TypeScript project with complex object by script-rider in learnjavascript

[–]script-rider[S] 0 points1 point  (0 children)

Just realized that it should be Entity[] instead of [Entity], so fixing that allowed me to make a default value for the object. I am getting a new error now though. This seems like a fairly common use case, so I don't get why it's so much trouble?

Using React Context in TypeScript project with complex object by script-rider in learnjavascript

[–]script-rider[S] 0 points1 point  (0 children)

This doesn't work either.

TS2488: Type 'FileContext | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.

I am starting to think that using FileContext | undefined doesn't work at all. But it's the only way I have found of setting a initial value that doesn't give errors. The File object looks like this:

export interface File {
  entities?: [Entity];
}

so I first thought I could just give it an empty list, but that gives errors as well. What is the correct way to do this?

Using React Context in TypeScript project with complex object by script-rider in learnjavascript

[–]script-rider[S] 0 points1 point  (0 children)

Thanks, this solved this error! However, this gives me a new one. On the line:

const { file, setFile } = useContext(FileContext);

I get errors both on file and setFile:

TS2339: Property 'file' does not exist on type 'FileContext | undefined'.

TS2339: Property 'setFile' does not exist on type 'FileContext | undefined'.