Using Depthkit.js

Tried bringing in an npm package for depthkit as an NPM Definition in needle but once setup I get this warning when importing it: File 'C:/Unity_Projects/NeedleWebDemos/Assets/Needle/depthkitNew~/index.ts' is not a module.. The index.ts seems to be generated by needle and is empty

Original Post on Discord

by user 103054507105067008

No it doesnt, you can remove it in the package.json

Is not a module is just because it doesnt expot anything yet when you just created it but you seem to try to import it

I’m really struggling at bringing another package into Needle, the depthkit.js I’m trying to bring in works fine otherwise when I run it via live server in VS Code from a fresh git pull.

Is there any kind of guide for bringing in an external dependency and importing it with Needle via typescript? Idk why I’m having so much trouble

by user 103054507105067008

Using this updated branch of depthkit.js, if I straight pull it down with git, open in VS code, npm install then run one of the source html files in Live Server via VS Code it is fine.
When I bring it into Needle I get issues with require and glsl.file when I import and try to run it via a .ts script

by user 103054507105067008

What you try to do is not much else then regular js dev here - you have a package.json (or multiple packages) and you install and import dependencies.

Going to try bringing it in via something custom like this, would this work?

  "dependencies": {
      "depthkit": "file: ./src/depthkit",

by user 103054507105067008

“Needle” at this point is nothing more :slightly_smiling_face:

If the path is correct yes, I’m not sure about the space

And I’m not familiar with depthkit so not sure how its setup / works

I’ll keep hacking at it, I was just hoping I missed something obvious, their npm package uses a really old version of three which I think is the issue so I wanted to change the package to the branch version and edit the files myself

by user 103054507105067008

Ok - sorry I cant help your more right now :confused:

Just checking what I’m doing, all the depthkit thing seems to be is a .js file you call to make a new ‘depthkit’ character in the scene. Something very simple I am trying to get working like this which is why I’m stumbling

import DepthKit from "depthkit/src";

    var depthkit = new DepthKit();
    character => {

by user 103054507105067008

Im not sure if its the same thing but I remember someone else tried to import some library that required some different import syntax. I’ll try to look it up later if you didnt solve it until then

not sure if its the same problem

Could be that, I frequently get does not provide an export named 'default' for the import which I sometimes get around by accident

by user 103054507105067008

was this thread i think: Discord

Works now for import DepthKit from "depthkit/src/depthkit.js"; which took the import to the correct file

by user 103054507105067008

Now I get the joyous depthkit.js?v=5c92bae1:18 Uncaught ReferenceError: require is not defined which I think I solved by importing browserify to allow require to run in the browser

by user 103054507105067008

Just not sure why require can run when I am using straight three.js from the source repo but in Needle/Vite is doesn’t run require

by user 103054507105067008