Needle Engine 4.2.6
Unity Integration
- Change Needle Engine dependency semver to ensure npm doesnt install 4.3 automatically
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Needle global scope for usage in commonjs or without a bundler. For example this allows to subscribe to the update event with Needle.onUpdate(ctx => console.log(ctx.time.time)).@needle-tools/engine@4.2.5 to be updated to @needle-tools/engine@4.3.0. This makes updating versions more predictable and deliberate using Unity."@needle-tools/engine": "npm:@needle-tools/engine@4.0.0" will lock the package version to 4.0.0. When using this syntax it’s up to you to manage the installed package version.
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
this.context.time.fps returning the FPS for the current frame (for a more stable FPS value smoothedFps can be used)multisampling property which is set to "auto" by default. By setting multisampling to a number it will force postprocessing to the configured samples.compress option did not apply progressive optimization and not produce texture or mesh LODs.
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Gizmos API
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
skybox-image and environment-image when configured in <needle-engine> web component. Previously it would only start loading the HDRi or EXR images after the root glTF file was finished loading. Now it will start downloading earlier which improves the time until the scene is ready to be displayed.
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Gizmos APIthis.context.time.fps returning the FPS for the current frame (for a more stable FPS value smoothedFps can be used)multisampling property which is set to "auto" by default. By setting multisampling to a number it will force postprocessing to the configured samples.<needle-engine> attributes for skybox-image and environment-image does now start earlier. Previously it would only start loading the HDRi or EXR images after the root glTF file was finished loading. Now it will start downloading earlier which improves the time until the scene is ready to be displayed.compress option did not apply progressive optimization and not produce texture or mesh LODs.
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
ObjectUtils.createPrimitive() now supports scale as arrayObjectUtils.createPrimitive("Cube", { scale: [1, .25, 1] } );getGamepad(<index>) function to query a connected gamepad. Example: this.context.input.getGamepad()lookAtScreenPoint() function which allows 3D object to look at points in 2D screen coordinates (e.g. your mouse position).import { Behaviour, lookAtScreenPoint } from "@needle-tools/engine";
export class LookAtMouse extends Behaviour {
update() {
lookAtScreenPoint(this.gameObject, this.context.input.mousePosition, this.context.mainCamera);
}
}
contactshadows attribute now allows you to specify a factor for controlling the darkness/lightness. E.g. <needle-engine contactshadows="1"> will make the shadows appear darker vs. <needle-engine contactshadows=".2"> will make the contact shadow appear lighter.background-image. E.g. `background-color attribute was not always applied. E.g. <needle-engine background-color="#ff3333">autoTarget does now automatically update the look at target after panning and not when rotating the camera (previously the target would be updated after any input but this resultet in undesireable behaviour when rotating around objects)background-color attribute then the default scene background color respects the user’s accessibility setting for prefer-dark or prefer-light. This means that the background color will be set to a default light or dark value.
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
<needle-engine background-color="#ffdddd55"> does now support transparency. For example: rgba(255, 255, 100, .5) or #ffdddd99 or transparent are valid values.freeOwnership() methoddevicePixelRatio option on Needle Context. This option controls the window.devicePixelRatio set on the renderer by Needle Engine (default auto). It can be set to manual to disable this behaviour or a custom number which will then be set on the renderer or composer.<needle-engine> are not overridden anymore by the camera component.manualChunks are not defined when preserveModules is set to truescreenshot() checks if XR is presenting
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Added
contactshadows attribute now allows you to specify a factor for controlling the darkness/lightness. E.g. <needle-engine contactshadows="1"> will make the shadows appear darker vs. <needle-engine contactshadows=".2"> will make the contact shadow appear lighter.background-color. For example: rgba(255, 255, 100, .5) or #ffdddd99 or transparent are valid values: <needle-engine background-color="rgba(255, 255, 100, .5)" />ObjectUtils.createPrimitive() now supports scale as arrayObjectUtils.createPrimitive("Cube", { scale: [1, .25, 1] } );getGamepad(<index>) function to query a connected gamepad. Example: this.context.input.getGamepad()lookAtScreenPoint() function which allows 3D object to look at points in 2D screen coordinates (e.g. your mouse position).import { Behaviour, lookAtScreenPoint } from "@needle-tools/engine";
export class LookAtMouse extends Behaviour {
update() {
lookAtScreenPoint(this.gameObject, this.context.input.mousePosition, this.context.mainCamera);
}
}
freeOwnership() methoddevicePixelRatio option on Needle Context. This option controls the window.devicePixelRatio set on the renderer by Needle Engine (default auto). It can be set to manual to disable this behaviour or a custom number which will then be set on the renderer or composer.Fixed
background-image. E.g. `background-color attribute was not always applied. E.g. <needle-engine background-color="#ff3333">screenshot() checks if XR is presentingObject3D objects in scenes arraysetCameraAndLookTarget was invertedclone method was not working and UI that was already in the scene could not be duplicated because of that.manualChunks are not defined when preserveModules is set to trueChanged
autoTarget does now automatically update the look at target after panning and not when rotating the camera (previously the target would be updated after any input but this resultet in undesireable behaviour when rotating around objects)background-color attribute then the default scene background color respects the user’s accessibility setting for prefer-dark or prefer-light. This means that the background color will be set to a default light or dark value.<needle-engine> are not overridden anymore by the camera component.2.16.0-pre.3
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
getKeyDown, getKeyPressed and getKeyUp to pass in key name to check the state of keyboard input, e.g. context.getKeyDown(<key>)needleNext plugin does now handle the license for passed in team or access tokens.next.config.js can be modified like so ... }, { modules: { webpack }, license: {team: "needle"} }) to pass in the name of a team (or a Needle Cloud access token).NEEDLE_CLOUD_TOKEN environment variable if no access token is provided.fastmode lerpmanualChunks should not be declared if rollupOutput.inlineDynamicImports is set to truesetCameraAndLookTarget with a Camera object (or transform) where the forward direction (+Z) did not match the camera’s look/render direction (-Z)
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
animations property of the scene object. This allows to add a Animation component to the root object of a loaded glTF to easily play animations.disconnect() now resets stateleaveRoom() does now reset the allowEditing property back to truefitCamera({immediate:true}) would not fit the camera immediately without lerping
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
NeedleEngineModelLoader namespace with methods to provide custom file loaders to load unsupported 3D model formats. For example to load STL files:import { NeedleEngineModelLoader } from "@needle-tools/engine";
// Register a callback for determining our custom loader mimetype
NeedleEngineModelLoader.onDetermineModelMimetype(args => {
// check if the mimetype is already provided by the server
if (args.contentType === "model/stl") {
return "model/stl";
}
// use URL extension if available
if (args.url.endsWith(".stl")) {
return "model/stl";
}
// check if first few bytes start with "solid"
// this is a very naive check, but it works for most cases
if(args.bytes[0] === 0x73 && args.bytes[1] === 0x74 && args.bytes[2] === 0x6c) {
return "model/stl";
}
return null;
});
// Register a callback for creating our custom loader
NeedleEngineModelLoader.onCreateCustomModelLoader(args => {
if (args.mimetype === "model/stl") {
const stlLoader = new STLLoader();
return stlLoader;
}
});
<needle-engine autostart="ar">ButtonsFactory.instance.qrButtonUrl = https://yourwebsite.demanualUpdate boolean. When enabled the ContactShadows component will not automatically re-render every frame. When enabled then set needsUpdate=true to manually schedule contact shadows re-renderloading-background attribute can be used to add custom styling like <needle-engine loading-background="#000" />. Alternatively the <needle-engine> web component or background can be styled.loading-background-color, loading-style, loading-text-color?stats) showing correct draw calls when using postprocessingfindObjectOfType does now also search components on the root scene object2.16.1
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
scripts directoryneedle.config.json file and the web project already has a public folder then the needle config asset directory will be set to public/needledev it will be used to start the dev server from Unity
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
makeFilesLocal in your vite.config.js:needlePlugins(command, needleConfig, {
makeFilesLocal: true
}),
preload option to true by defaultBilling role
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples
PostProcessingEffectPriority to ensure effects are correctly sorted (e.g. before DepthOfField)screenshot correctly handling custom devicePixelRatio
Download Unity Plugin
Install from NPM
Changelog on Github
Needle Engine API
Get started
Samples