You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Creating responsive 3D websites doesn't have to be complicated. This site offers practical solutions and techniques on how to seamlessly and responsively integrate 3D content into your existing web layout, specifically using three.js and the Needle Engine."
2
+
description: "Learn how to easily create 3D websites that are responsive on any screen with Needle Engine and three.js"
3
3
---
4
4
5
5
# Responsive 3D Webdesign
6
6
7
+
Needle Engine offers several building blocks to make building responsive 3d websites easy. Learn how to use and combine Focus Rect and ViewBox features:
8
+
7
9
## Focus Rect
8
-
The main purpose of FocusRect is to make your website responsive and ensure the 3D element is always adjusting to the available space. The 3D content moves dynamic with your existing HTML layout.
10
+
Use the Needle Engine focus rect feature to adjust the center of your 3D scene using CSS. This is the basic building block for responsive layouts. It can be enabled with one line of code and no changes to your scene are required.
Set the element you like to focus on simply by querying an HTML element on your website. You then set this element using the method: [```context.setCameraFocusRect(<element>)```](https://engine.needle.tools/docs/api/classes/Engine_Core.Context.html#setcamerafocusrect).
18
+
Set the element to focus on by querying an HTML element on your website. You then set this element using the [```setCameraFocusRect(<element>)```](https://engine.needle.tools/docs/api/classes/Engine_Core.Context.html#setcamerafocusrect) method.
13
19
14
-
For example `onStart`[hook](/scripting.md#hooks) in your Needle Engine code (e.g., in main.ts) to query the FocusRect element and pass it to the camera.
20
+
For example using the `onStart`[hook](/scripting.md#hooks) in your Needle Engine code (e.g., in main.ts) to query the element and pass it to Needle Engine.
15
21
16
22
```ts twoslash
17
23
import"@needle-tools/engine";
@@ -27,26 +33,20 @@ onStart((ctx)=>{
27
33
28
34
[View needle-engine attributes for more](/reference/needle-engine-attributes.md)
29
35
30
-
### Links to Samples
36
+
### Focus Rect Samples
31
37
[Demo Webpage Sword and Shield](https://portfolio-header-demo-z23hmxb19zenk-19zenk.needle.run/)
[ViewBox](https://engine.needle.tools/docs/api/classes/Built-in_Components.ViewBox.html) can be used to automatically fit a certain box area into the camera view - no matter your screen size or aspect ratio.
45
+
The [ViewBox](https://engine.needle.tools/docs/api/classes/Built-in_Components.ViewBox.html) can be used to automatically fit a certain box area into the camera view - no matter your screen size or aspect ratio.
45
46
46
-
This component can be used to automatically fit a certain box area into the camera view - no matter your screen size or aspect ratio.
47
-
This is useful for example to frame a character or object in the center of the screen and ensure it is always fully visible. You can also animate or scale the viewbox to create zoom or framing effects.
47
+
This is useful for example to frame a character or object in the center of the screen and ensure it is always fully visible. The Viewbox can also be animated or scaled to create zoom effects or to adjust the visible area.
0 commit comments