1.19.0 • Published 1 month ago

@shopware-ag/dive v1.19.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

About

DIVE is a spatial framework made by and optimized for Shopware. It can be used directly integrated in a Shopware frontend such as Storefront or in any other frontend you want to use it in, it is not tied to Shopware.

DIVE supplies your frontend application with all needed tooling to set up a basic 3D application with event-based controls called "Actions". For further information, see Getting started.

Installation

npm:

npm install @shopware-ag/dive

yarn:

yarn add @shopware-ag/dive

Formatter

DIVE uses Prettier as a preconfigured formatter.

Setup in Shopware

Don't forget to include DIVE in your webpack.config.js:

const path = require('path');

module.exports = () => {
    return {
        ...
        resolve: {
            extensions: ['.ts', '.cjs', '.js'],
            alias: {
                three: path.resolve(__dirname, 'path/to/node_modules/three'),
                "@shopware-ag/dive": path.resolve(__dirname, 'path/to/node_modules/@shopware-ag/dive'),
            }
        },
        ...
        module: {
            rules: [
                ...
                {
                    test: /\.(js|ts)$/,
                    loader: 'swc-loader',
                    include: [
                        path.resolve(__dirname, 'path/to/node_modules/three'),
                        path.resolve(__dirname, 'path/to/node_modules/@shopware-ag/dive')
                    ],
                    options: {
                        jsc: {
                            parser: {
                                syntax: 'typescript',
                            },
                            target: 'es2022',
                        },
                    },
                },
                ...
            ],
        }
    };
};

Quick View

QuickView is used to quickly display your assets with as few lines of code as possible. Simply call the static QuickView() method (with your data-uri as a parameter) to create an instance of DIVE with your asset to use in further code.

import { DIVE } from '@shopware-ag/dive';

const dive = DIVE.QuickView('your/asset/uri.glb'); // <-- call QuickView()

const myCanvasWrapper = document.createElement('div');
myCanvasWrapper.appendChild(dive.Canvas);

Getting started

Import:

import { DIVE } from '@shopware-ag/dive'; // <-- import DIVE

Instantiate:

import { DIVE } from '@shopware-ag/dive';

const dive = new DIVE(); // <-- instantiate DIVE

DIVE supplies your application with a HTMLCanvasElement that it uses as a render target. After instantiating, you can use the supplied canvas within you frontend code to attach it to your DOM.

const dive = new DIVE();

const myCanvasWrapper = document.createElement('div'); // <-- create wrapper element
myCanvasWrapper.appendChild(dive.Canvas); // <-- reference DIVE canvas

To interact with your newly created DIVE instance you have to perform actions via DIVECommunication. For further information, see Actions.

const dive = new DIVE();

const myCanvasWrapper = document.createElement('div');
myCanvasWrapper.appendChild(dive.Canvas);

const com = dive.Communication; // <-- reference DIVECommunication

com.PerformAction('SET_CAMERA_TRANSFORM', {
    // <-- perform action on DIVECommunication
    position: { x: 0, y: 2, z: 2 },
    target: { x: 0, y: 0.5, z: 0 },
});

Actions

Actions symbolize the communication between frontend and 3D space. All actions can be performed anywhere, no matter if you are in frontend or 3D.

In addition to the impact that specific actions have, every action can be subscribed to.

const myCanvasWrapper = document.createElement('div');
const dive = new DIVE();

myCanvasWrapper.appendChild(dive.Canvas);

const com = dive.Communication;

com.Subscribe('SET_CAMERA_TRANSFORM', () => {
    // <-- add subscription
    // do something
});

com.PerformAction('SET_CAMERA_TRANSFORM', {
    position: { x: 0, y: 2, z: 2 },
    target: { x: 0, y: 0.5, z: 0 },
});

Subscribing to an action returns a unsubscribe()-callback that should be executed when not needed anymore.

const myCanvasWrapper = document.createElement('div');
const dive = new DIVE();

myCanvasWrapper.appendChild(dive.Canvas);

const com = dive.Communication;

const unsubscribe = com.Subscribe('SET_CAMERA_TRANSFORM', () => {
    // <-- save unsubscribe callback
    // do something
});

com.PerformAction('SET_CAMERA_TRANSFORM', {
    position: { x: 0, y: 2, z: 2 },
    target: { x: 0, y: 0.5, z: 0 },
});

unsubscribe(); // <-- execute unsubscribe callback when done

Actions (List)

In the following you find a list of all available actions to perform on DIVECommunication class via com.PerformAction().

1.18.1

6 months ago

1.18.0

6 months ago

1.18.5

4 months ago

1.16.21

8 months ago

1.18.4

4 months ago

1.16.20

8 months ago

1.18.3

4 months ago

1.18.2

6 months ago

1.16.25

8 months ago

1.16.24

8 months ago

1.16.23

8 months ago

1.16.22

8 months ago

1.16.16-beta.0

8 months ago

1.16.10

8 months ago

1.16.14

8 months ago

1.16.13

8 months ago

1.16.12

8 months ago

1.16.11

8 months ago

1.18.5-beta.2

4 months ago

1.16.18

8 months ago

1.18.5-beta.3

4 months ago

1.16.17

8 months ago

1.18.5-beta.0

4 months ago

1.16.16

8 months ago

1.18.5-beta.1

4 months ago

1.16.15

8 months ago

1.16.19

8 months ago

1.19.0

4 months ago

1.16.26-beta.3

7 months ago

1.16.26-beta.1

7 months ago

1.16.26-beta.2

7 months ago

1.16.26-beta.0

8 months ago

2.0.1-beta.8

1 month ago

2.0.1-beta.9

1 month ago

1.16.7

8 months ago

1.16.6

8 months ago

1.16.25-beta.1

7 months ago

1.16.5

8 months ago

1.16.4

8 months ago

1.16.9

8 months ago

1.16.8

8 months ago

1.19.1-beta.0

3 months ago

2.0.1-beta.2

2 months ago

1.19.1-beta.2

3 months ago

2.0.1-beta.3

2 months ago

1.19.1-beta.1

3 months ago

2.0.1-beta.0

2 months ago

1.19.1-beta.4

3 months ago

2.0.1-beta.1

2 months ago

1.19.1-beta.3

3 months ago

2.0.1-beta.6

1 month ago

1.19.1-beta.6

3 months ago

2.0.1-beta.7

1 month ago

1.19.1-beta.5

3 months ago

2.0.1-beta.4

2 months ago

1.19.1-beta.8

3 months ago

2.0.1-beta.5

2 months ago

1.19.1-beta.7

3 months ago

1.19.1-beta.9

3 months ago

1.19.1-beta.10

2 months ago

1.17.2

6 months ago

1.17.1

7 months ago

1.17.0

7 months ago

2.0.1-beta.10

1 month ago

1.16.15-beta.0

8 months ago

1.16.14-beta.0

8 months ago

1.16.3

8 months ago

1.16.2

8 months ago

1.16.1

8 months ago

1.16.0

9 months ago

1.15.5

9 months ago

1.15.4

9 months ago

1.15.3

9 months ago

1.15.0

10 months ago

1.15.2

9 months ago

1.15.1

9 months ago

1.14.0

10 months ago

1.13.0

10 months ago

1.12.1

10 months ago

1.12.0

10 months ago

1.11.0

10 months ago

1.10.0

10 months ago

1.9.0

10 months ago

1.8.0

11 months ago

1.7.0

11 months ago

1.6.5

11 months ago

1.6.4

12 months ago

1.6.3

12 months ago

1.6.2

12 months ago

1.6.1

12 months ago

1.6.0

12 months ago

1.5.0

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago