├── .eslintrc
├── .github
└── workflows
│ ├── php-unit.yml
│ ├── test-js.yml
│ └── wordpress.yml
├── .gitignore
├── .prettierrc
├── .svnignore
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── admin
└── three-object-viewer-settings
│ ├── App.js
│ ├── App.test.js.test
│ ├── index.js
│ └── init.php
├── assets
└── wporg
│ ├── banner-1544x500.jpg
│ ├── banner-772x250.jpg
│ ├── icon-128x128.png
│ └── icon-256x256.png
├── babel.config.js
├── bin
└── install-wp-tests.sh
├── blocks
├── environment
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── components
│ │ ├── ContextBridgeComponent.js
│ │ ├── Controls.js
│ │ ├── EditControls.js
│ │ ├── EditorPluginProvider.js
│ │ ├── EnvironmentFront.js
│ │ ├── FrontPluginProvider.js
│ │ ├── Networking.js
│ │ ├── Player.js
│ │ ├── TeleportTravel.js
│ │ ├── ThreeObjectEdit.js
│ │ ├── core
│ │ │ └── front
│ │ │ │ ├── ModelObject.js
│ │ │ │ ├── NPCObject.js
│ │ │ │ ├── Portal.js
│ │ │ │ ├── TextObject.js
│ │ │ │ ├── ThreeAudio.js
│ │ │ │ ├── ThreeImage.js
│ │ │ │ ├── ThreeLight.js
│ │ │ │ ├── ThreeSky.js
│ │ │ │ └── ThreeVideo.js
│ │ └── p2pcf
│ │ │ └── p2pcf.js
│ ├── editor.scss
│ ├── frontend.js
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── model-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── components
│ │ └── ModelEdit.js
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── npc-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── components
│ │ └── ModelEdit.js
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── sky-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── spawn-point-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── three-audio-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── three-image-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── three-light-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── three-object-block
│ ├── Edit.js
│ ├── Save.js
│ ├── block.json
│ ├── components
│ │ ├── TeleportTravel.js
│ │ ├── ThreeObjectEdit.js
│ │ └── ThreeObjectFront.js
│ ├── editor.scss
│ ├── frontend.js
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── three-portal-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── three-text-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
└── three-video-block
│ ├── Edit.js
│ ├── Edit.test.js
│ ├── Save.js
│ ├── block.json
│ ├── editor.scss
│ ├── index.js
│ ├── init.php
│ └── style.scss
├── composer.json
├── composer.lock
├── docker-compose.yml
├── inc
├── assets
│ ├── audio_icon.png
│ ├── default_grid.glb
│ └── light_icon.png
├── avatars
│ ├── 3ov_default_avatar.vrm
│ ├── Idle.fbx
│ ├── Running.fbx
│ ├── friendly.fbx
│ ├── talking.fbx
│ └── walking.fbx
├── fonts
│ └── roboto.woff
├── functions.php
├── hooks.php
├── threeobjectloaderinit
│ ├── index.css
│ └── index.js
└── utils
│ └── draco
│ └── draco_decoder.js
├── languages
├── three-object-viewer-es_MX-three-object-viewer-environment-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-model-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-npc-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-settings.json
├── three-object-viewer-es_MX-three-object-viewer-sky-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-spawn-point-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-three-audio-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-three-image-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-three-light-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-three-portal-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-three-text-block-editor-script.json
├── three-object-viewer-es_MX-three-object-viewer-three-video-block-editor-script.json
├── three-object-viewer-es_MX.mo
├── three-object-viewer-es_MX.po
├── three-object-viewer-ja-three-object-viewer-environment-editor-script.json
├── three-object-viewer-ja-three-object-viewer-model-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-npc-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-settings.json
├── three-object-viewer-ja-three-object-viewer-sky-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-spawn-point-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-three-audio-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-three-image-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-three-light-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-three-portal-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-three-text-block-editor-script.json
├── three-object-viewer-ja-three-object-viewer-three-video-block-editor-script.json
├── three-object-viewer-ja.mo
├── three-object-viewer-ja.po
├── three-object-viewer.mo
├── three-object-viewer.po
└── three-object-viewer.pot
├── package.js
├── package.json
├── php
└── Plugin.php
├── phpcs.xml.dist
├── phpunit-integration.xml
├── phpunit-unit.xml
├── plugin-build
├── .gitignore
└── .gitkeep
├── pluginMachine.json
├── readme.txt
├── rename.js
├── tests
├── Integration
│ └── EnvironmentTest.php
├── Unit
│ ├── EnvironmentTest.php
│ └── TestCase.php
└── bootstrap.php
├── three-object-viewer.php
├── webpack.config.js
└── yarn.lock
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/.github/workflows/php-unit.yml:
--------------------------------------------------------------------------------
1 | name: PHP Unit Tests
2 |
3 | on: push
4 |
5 | jobs:
6 | test:
7 | runs-on: ubuntu-latest
8 | strategy:
9 | matrix:
10 | php-versions: [7.2, 7.3, 7.4]
11 |
12 | steps:
13 | - uses: actions/checkout@v2
14 | - name: Setup PHP
15 | uses: shivammathur/setup-php@v2
16 | with:
17 | php-version: ${{ matrix.php-versions }}
18 | # Install composer with cache
19 | - name: Get Composer Cache Directory
20 | id: get-composer-cache-dir # Instead of composer-cache
21 | run: |
22 | echo "::set-output name=dir::$(composer config cache-files-dir)"
23 |
24 | - name: Cache Composer packages
25 | id: composer-cache
26 | uses: actions/cache@v2
27 | with:
28 | path: vendor
29 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
30 | restore-keys: |
31 | ${{ runner.os }}-php-
32 |
33 | - name: Install dependencies
34 | if: steps.composer-cache.outputs.cache-hit != 'true'
35 | run: composer install --prefer-dist --no-progress
36 |
37 | # Run unit tests
38 | - name: Unit Tests
39 | run: composer test:unit
40 |
--------------------------------------------------------------------------------
/.github/workflows/test-js.yml:
--------------------------------------------------------------------------------
1 | name: JavaScripts
2 |
3 | on: [push]
4 |
5 | jobs:
6 | buildAndTest:
7 | name: Test
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v1
11 | - uses: actions/setup-node@v1
12 | with:
13 | node-version: '12'
14 | - name: Install dependencies
15 | run: yarn
16 | - name: Test
17 | run: yarn test --ci
18 |
--------------------------------------------------------------------------------
/.github/workflows/wordpress.yml:
--------------------------------------------------------------------------------
1 | name: WordPress Tests
2 |
3 | on: [push]
4 |
5 | env:
6 | WP_TESTS_DIR: /github/home/wp-tests/wordpress-tests-lib
7 | WP_CORE_DIR: /github/home/wp-tests/wordpress
8 |
9 | jobs:
10 | test:
11 | runs-on: ubuntu-latest
12 | strategy:
13 | matrix:
14 | php-version: [7.2, 7.3, 7.4]
15 | wordpress-version: [latest]
16 | container:
17 | image: junaidbhura/wp-tests:php-${{ matrix.php-version }}
18 | services:
19 | mysql:
20 | image: mysql:5.7.27
21 | options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
22 | env:
23 | MYSQL_ROOT_PASSWORD: root
24 |
25 | steps:
26 | # Setup
27 | - name: Checkout repository
28 | uses: actions/checkout@v1
29 |
30 | ## Install
31 | - name: Get Composer Cache Directory
32 | id: get-composer-cache-dir # Instead of composer-cache
33 | run: |
34 | echo "::set-output name=dir::$(composer config cache-files-dir)"
35 |
36 | - name: Cache Composer packages
37 | id: composer-cache
38 | uses: actions/cache@v2
39 | with:
40 | path: vendor
41 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
42 | restore-keys: |
43 | ${{ runner.os }}-php-
44 |
45 | - name: Install dependencies
46 | if: steps.composer-cache.outputs.cache-hit != 'true'
47 | run: composer install --prefer-dist --no-progress
48 |
49 | ## Install test suite
50 | - name: Install WordPress test suite
51 | run: bash bin/install-wp-tests.sh wordpress_test root root mysql ${{ matrix.wordpress-version }}
52 |
53 | ## Run integration tests
54 | - name: Tests
55 | run: composer test:wordpress
56 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Logs
3 | logs
4 | *.log
5 | npm-debug.log*
6 | yarn-debug.log*
7 | yarn-error.log*
8 | lerna-debug.log*
9 | .DS_Store
10 |
11 | # Diagnostic reports (https://nodejs.org/api/report.html)
12 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13 |
14 | # Dependency directories
15 | node_modules/
16 | vendor/
17 |
18 | # dotenv environment variables file
19 | .env
20 | .env.test
21 |
22 | vendor
23 | wordpress
24 | build
25 | pro/
26 | .phpunit.result.cache
27 | plugin-build/pro/three-object-viewer/*
28 | !plugin-build/pro/three-object-viewer/.gitkeep
29 | plugin-build/free/three-object-viewer/*
30 | !plugin-build/free/three-object-viewer/.gitkeep
31 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": true,
3 | "singleQuote": false,
4 | "trailingComma": "none"
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/.svnignore:
--------------------------------------------------------------------------------
1 | .git
2 | .github
3 | .gitignore
4 | .gitattributes
5 | .DS_Store
6 | .babelrc
7 | .cache
8 | .codeclimate*
9 | .idea
10 | .parcel-cache
11 | .eslintignore
12 | .eslintrc.json
13 | .eslintrc.js
14 | .circleci
15 | .sass-cache
16 | .editorconfig
17 | .husky
18 | .env.testing*
19 | .prettier*
20 | .husky
21 | .phpcs.xml.dist
22 | .svnignore
23 | .zipignore
24 | .docker
25 | docs
26 | node_modules
27 | scripts
28 | tests
29 | *phpunit*
30 | *bin*
31 | *config*
32 | *tests*
33 | *composer.json*
34 | *composer.lock*
35 | webpack.config.js
36 | pluginMachine.json
37 | babel.config.json
38 | phpunit-unit.xml
39 | phpunit-integration.xml
40 | phpcs.xml.dist
41 | yarn.lock
42 | yarn-error.log
43 | jest.config.js
44 | package.json
45 | package-lock.json
46 | docker-compose.yml
47 | docker-composer-phpunit.yml
48 | Makefile
49 | *vendor*
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
3 | "editor.codeActionsOnSave": {
4 | "source.fixAll": true
5 | },
6 | "[javascript]": {
7 | "editor.defaultFormatter": "vscode.typescript-language-features"
8 | },
9 | }
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Three Object Viewer
2 |
3 | [](https://pluginmachine.com)
4 |
5 | ## Installation
6 |
7 | Download the from WordPress or install by searching for "Three Object Viewer" in the plugin repository in wp-admin.
8 | https://wordpress.org/plugins/three-object-viewer/
9 |
10 |
11 | ## Local Development
12 |
13 | - Git clone:
14 | - `git clone git@github.com:antpb/three-object-viewer.git`
15 | - Install javascript dependencies
16 | - `yarn`
17 | - Install php dependencies
18 | - `composer install`
19 |
20 | ## Working With JavaScript
21 |
22 | - Build JS/CSS
23 | - `yarn build`
24 | - Start JS/CSS for development - currently broken
25 | - `yarn start`
26 | - Test changed files - pending tests
27 | - `yarn test --watch`
28 | - Test all files once
29 | - `yarn test`
30 | - `yarn test --ci`
31 |
32 |
33 | ## Working With PHP
34 |
35 | ### Autoloader
36 |
37 | PHP classes should be located in the "php" directory and follow the [PSR-4 standard](https://www.php-fig.org/psr/psr-4/).
38 |
39 | The root namespace is `threeObjectViewer`.
40 |
41 |
42 |
43 | ### Tests
44 | - Run unit tests
45 | - `composer test:unit`
46 | - Run WordPress tests
47 | - `composer test:wordpress`
48 | - See local development instructions for how to run with Docker.
49 | - Run unit tests and WordPress tests
50 | - `composer test`
51 |
52 | ### Linter
53 |
54 | [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) is installed for linting and [automatic code fixing](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically).
55 |
56 | - Run linter and autofix
57 | - `composer fixes`
58 | - Run linter to identify issues.
59 | - `compose sniffs`
60 |
61 | ## Local Development Environment
62 |
63 | A [docker-compose](https://docs.docker.com/samples/wordpress/)-based local development environment is provided.
64 |
65 | - Start server
66 | - `docker-compose up -d`
67 | - Acess Site
68 | - [http://localhost:6039](http://localhost:6039)
69 | - WP CLI
70 | - Run any WP CLI command in container:
71 | - `docker-compose run wpcli wp ...`
72 | - Setup site with WP CLI
73 | - `docker-compose run wpcli wp core install --url=http://localhost:6039 --title="Three Object Viewer" --admin_user=admin0 --admin_email=something@example.com`
74 | - `docker-compose run wpcli wp user create admin admin@example.com --role=administrator --user_pass=pass`
75 |
76 |
77 | There is a special phpunit container for running WordPress tests, with WordPress and MySQL configured.
78 |
79 | - Enter container
80 | - `docker-compose run phpunit`
81 | - Composer install
82 | - `composer install`
83 | - Test
84 | - `composer test:wordpress`
85 |
86 |
--------------------------------------------------------------------------------
/admin/three-object-viewer-settings/App.test.js.test:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import ReactDOM from "react-dom";
3 | import App from "./App";
4 | it("renders without crashing", () => {
5 | const div = document.createElement("div");
6 | ReactDOM.render(
10 | {attributes.deviceTarget} 11 |
12 |13 | {attributes.threeObjectUrl} 14 |
15 |16 | {attributes.hdr} 17 |
18 |{attributes.scale}
19 |20 | {attributes.bg_color} 21 |
22 |{attributes.zoom}
23 |24 | {attributes.hasZoom ? 1 : 0} 25 |
26 |27 | {attributes.hasTip ? 1 : 0} 28 |
29 |30 | {attributes.positionY} 31 |
32 |33 | {attributes.rotationY} 34 |
35 |{attributes.scale}
36 |37 | {attributes.threePreviewImage} 38 |
39 |40 | {attributes.animations} 41 |
42 |10 | {attributes.threeObjectUrl} 11 |
12 |{attributes.scaleX}
13 |{attributes.scaleY}
14 |{attributes.scaleZ}
15 |16 | {attributes.positionX} 17 |
18 |19 | {attributes.positionY} 20 |
21 |22 | {attributes.positionZ} 23 |
24 |25 | {attributes.rotationX} 26 |
27 |28 | {attributes.rotationY} 29 |
30 |31 | {attributes.rotationZ} 32 |
33 |34 | {attributes.animations} 35 |
36 |37 | {attributes.collidable ? 1 : 0} 38 |
39 |{attributes.alt}
40 |Click and drag ^
103 | )} 104 | > 105 | ); 106 | } 107 | -------------------------------------------------------------------------------- /blocks/model-block/editor.scss: -------------------------------------------------------------------------------- 1 | 2 | .wp-block-three-object-block { 3 | border: 1px dotted #f00; 4 | } 5 | .glb-preview-container { 6 | padding: 100px; 7 | text-align: center; 8 | align-items: center; 9 | align-content: center; 10 | background-color:#f2f2f2; 11 | } 12 | 13 | .glb-preview-container button{ 14 | padding: 15px; 15 | border-radius: 30px; 16 | } 17 | 18 | .glb-preview-container button:hover{ 19 | border-radius: 30px; 20 | // background-color:rgb(156, 199, 0); 21 | cursor: pointer; 22 | } 23 | 24 | .three-object-block-tip { 25 | overflow-wrap: break-word; 26 | background-color: black; 27 | color: white; 28 | padding: 10px; 29 | font-weight: 500; 30 | max-width: 160px; 31 | font-size: 12px; 32 | margin-top: 0px; 33 | margin: 0 auto; 34 | text-align: center; 35 | } 36 | 37 | .three-object-block-url-input { 38 | padding-bottom: 20px; 39 | } 40 | 41 | .three-object-block-url-input input{ 42 | height: 40px; 43 | } 44 | 45 | .block-editor-block-inspector .components-base-control.position-inputs:last-child { 46 | margin-bottom: 24px !important; 47 | } 48 | .block-editor-block-inspector .components-base-control.position-inputs { 49 | padding-right: 5px; 50 | } 51 | -------------------------------------------------------------------------------- /blocks/model-block/index.js: -------------------------------------------------------------------------------- 1 | import { registerBlockType } from "@wordpress/blocks"; 2 | import Edit from "./Edit"; 3 | import Save from "./Save"; 4 | import { useBlockProps } from "@wordpress/block-editor"; 5 | 6 | const icon = ( 7 | 17 | ); 18 | 19 | const blockConfig = require("./block.json"); 20 | registerBlockType(blockConfig.name, { 21 | ...blockConfig, 22 | icon, 23 | apiVersion: 2, 24 | edit: Edit, 25 | save: Save, 26 | deprecated: [ 27 | { 28 | attributes: { 29 | scaleX: { 30 | type: "int", 31 | default:1 32 | }, 33 | name: { 34 | type: "string" 35 | }, 36 | scaleY: { 37 | type: "int", 38 | default:1 39 | }, 40 | scaleZ: { 41 | type: "int", 42 | default:1 43 | }, 44 | positionX: { 45 | type: "int", 46 | default:0 47 | }, 48 | positionY: { 49 | type: "int", 50 | default:0 51 | }, 52 | positionZ: { 53 | type: "int", 54 | default:0 55 | }, 56 | rotationX: { 57 | type: "int", 58 | default:0 59 | }, 60 | rotationY: { 61 | type: "int", 62 | default:0 63 | }, 64 | rotationZ: { 65 | type: "int", 66 | default:0 67 | }, 68 | threeObjectUrl: { 69 | type: "string", 70 | default: null 71 | }, 72 | animations: { 73 | type: "string", 74 | default: "" 75 | }, 76 | alt: { 77 | type: "string", 78 | default: "" 79 | }, 80 | collidable: { 81 | type: "boolean", 82 | default: false 83 | } 84 | }, 85 | save(props) { 86 | return ( 87 |91 | {props.attributes.threeObjectUrl} 92 |
93 |{props.attributes.scaleX}
94 |{props.attributes.scaleY}
95 |{props.attributes.scaleZ}
96 |97 | {props.attributes.positionX} 98 |
99 |100 | {props.attributes.positionY} 101 |
102 |103 | {props.attributes.positionZ} 104 |
105 |106 | {props.attributes.rotationX} 107 |
108 |109 | {props.attributes.rotationY} 110 |
111 |112 | {props.attributes.rotationZ} 113 |
114 |115 | {props.attributes.animations} 116 |
117 |118 | {props.attributes.collidable ? 1 : 0} 119 |
120 |{props.attributes.alt}
121 |10 | {attributes.threeObjectUrl} 11 |
12 |13 | {attributes.positionX} 14 |
15 |16 | {attributes.positionY} 17 |
18 |19 | {attributes.positionZ} 20 |
21 |22 | {attributes.rotationX} 23 |
24 |25 | {attributes.rotationY} 26 |
27 |28 | {attributes.rotationZ} 29 |
30 |31 | {attributes.name} 32 |
33 |34 | {attributes.defaultMessage} 35 |
36 |37 | {attributes.personality} 38 |
39 |40 | {attributes.objectAwareness ? 1 : 0} 41 |
42 |Click and drag ^
103 | )} 104 | > 105 | ); 106 | } 107 | -------------------------------------------------------------------------------- /blocks/npc-block/editor.scss: -------------------------------------------------------------------------------- 1 | 2 | .wp-block-three-object-block { 3 | border: 1px dotted #f00; 4 | } 5 | .glb-preview-container { 6 | padding: 100px; 7 | text-align: center; 8 | align-items: center; 9 | align-content: center; 10 | background-color:#f2f2f2; 11 | } 12 | 13 | .glb-preview-container button{ 14 | padding: 15px; 15 | border-radius: 30px; 16 | } 17 | 18 | .glb-preview-container button:hover{ 19 | border-radius: 30px; 20 | // background-color:rgb(156, 199, 0); 21 | cursor: pointer; 22 | } 23 | 24 | .three-object-block-tip { 25 | overflow-wrap: break-word; 26 | background-color: black; 27 | color: white; 28 | padding: 10px; 29 | font-weight: 500; 30 | max-width: 160px; 31 | font-size: 12px; 32 | margin-top: 0px; 33 | margin: 0 auto; 34 | text-align: center; 35 | } 36 | 37 | .three-object-block-url-input { 38 | padding-bottom: 20px; 39 | } 40 | 41 | .three-object-block-url-input input{ 42 | height: 40px; 43 | } 44 | 45 | .block-editor-block-inspector .components-base-control.position-inputs:last-child { 46 | margin-bottom: 24px !important; 47 | } 48 | .block-editor-block-inspector .components-base-control.position-inputs { 49 | padding-right: 5px; 50 | } 51 | -------------------------------------------------------------------------------- /blocks/npc-block/init.php: -------------------------------------------------------------------------------- 1 | _x( 'NPC Block', 'block title', 'three-object-viewer' ), 10 | 'description' => _x( 'A NPC to live in your environment', 'block description', 'three-object-viewer' ), 11 | ] ); 12 | } 13 | }); 14 | -------------------------------------------------------------------------------- /blocks/npc-block/style.scss: -------------------------------------------------------------------------------- 1 | .wp-block-three-object-block { 2 | background-color: #fff; 3 | color: #000; 4 | padding: 2px; 5 | } 6 | 7 | .wp-block-three-object-block { 8 | border: 1px dotted #f00; 9 | } 10 | .glb-preview-container { 11 | padding: 100px; 12 | text-align: center; 13 | align-items: center; 14 | align-content: center; 15 | background-color:#f2f2f2; 16 | } 17 | 18 | .glb-preview-container button{ 19 | padding: 10px; 20 | border-radius: 30px; 21 | background-color:#333; 22 | color: white; 23 | } 24 | 25 | .three-object-block-tip { 26 | overflow-wrap: break-word; 27 | background-color: black; 28 | color: white; 29 | padding: 10px; 30 | font-weight: 500; 31 | max-width: 160px; 32 | font-size: 14px; 33 | margin-top: 0px; 34 | margin: 0 auto; 35 | text-align: center; 36 | } 37 | 38 | .glb-preview-container button:hover{ 39 | padding: 10px; 40 | border-radius: 30px; 41 | background-color:rgb(69, 69, 69); 42 | color: white; 43 | cursor: pointer; 44 | } -------------------------------------------------------------------------------- /blocks/sky-block/Edit.test.js: -------------------------------------------------------------------------------- 1 | //Import React 2 | import React from "react"; 3 | //Import test renderer 4 | import { render, fireEvent, cleanup } from "@testing-library/react"; 5 | //Import component to test 6 | import { Editor } from "./Edit"; 7 | 8 | describe("Editor componet", () => { 9 | afterEach(cleanup); 10 | it("matches snapshot when selected", () => { 11 | const onChange = jest.fn(); 12 | const { container } = render( 13 |{attributes.skyUrl}
10 |{attributes.distance}
11 |{attributes.rayleigh}
12 |{attributes.sunPositionX}
13 |{attributes.sunPositionY}
14 |{attributes.sunPositionZ}
15 |{props.attributes.skyUrl}
40 |10 | {attributes.positionX} 11 |
12 |13 | {attributes.positionY} 14 |
15 |16 | {attributes.positionZ} 17 |
18 |19 | {attributes.rotationX} 20 |
21 |22 | {attributes.rotationY} 23 |
24 |25 | {attributes.rotationZ} 26 |
27 |{attributes.audioUrl}
10 |{attributes.scaleX}
11 |{attributes.scaleY}
12 |{attributes.scaleZ}
13 |14 | {attributes.positionX} 15 |
16 |17 | {attributes.positionY} 18 |
19 |20 | {attributes.positionZ} 21 |
22 |23 | {attributes.rotationX} 24 |
25 |26 | {attributes.rotationY} 27 |
28 |29 | {attributes.rotationZ} 30 |
31 |32 | {attributes.autoPlay ? '1' : '0'} 33 |
34 |35 | {attributes.loop ? '1' : '0'} 36 |
37 |38 | {attributes.volume} 39 |
40 |41 | {attributes.positional ? '1' : '0'} 42 |
43 |44 | {attributes.coneInnerAngle} 45 |
46 |47 | {attributes.coneOuterAngle} 48 |
49 |50 | {attributes.coneOuterGain} 51 |
52 |53 | {attributes.distanceModel} 54 |
55 |56 | {attributes.maxDistance} 57 |
58 |59 | {attributes.refDistance} 60 |
61 |62 | {attributes.rolloffFactor} 63 |
64 |{attributes.imageUrl}
10 |{attributes.scaleX}
11 |{attributes.scaleY}
12 |{attributes.scaleZ}
13 |14 | {attributes.positionX} 15 |
16 |17 | {attributes.positionY} 18 |
19 |20 | {attributes.positionZ} 21 |
22 |23 | {attributes.rotationX} 24 |
25 |26 | {attributes.rotationY} 27 |
28 |29 | {attributes.rotationZ} 30 |
31 |32 | {attributes.aspectHeight} 33 |
34 |35 | {attributes.aspectWidth} 36 |
37 |38 | {attributes.transparent ? 1 : 0} 39 |
40 |10 | {attributes.positionX} 11 |
12 |13 | {attributes.positionY} 14 |
15 |16 | {attributes.positionZ} 17 |
18 |19 | {attributes.rotationX} 20 |
21 |22 | {attributes.rotationY} 23 |
24 |25 | {attributes.rotationZ} 26 |
27 |28 | {attributes.type} 29 |
30 |31 | {attributes.color} 32 |
33 |34 | {attributes.intensity} 35 |
36 |37 | {attributes.distance} 38 |
39 |40 | {attributes.decay} 41 |
42 |43 | {attributes.targetX} 44 |
45 |46 | {attributes.targetY} 47 |
48 |49 | {attributes.targetZ} 50 |
51 |52 | {attributes.angle} 53 |
54 |55 | {attributes.penumbra} 56 |
57 |10 | { attributes.deviceTarget } 11 |
12 |13 | { attributes.threeObjectUrl } 14 |
15 |{ attributes.scale }
16 |17 | { attributes.bg_color } 18 |
19 |{ attributes.zoom }
20 |21 | { attributes.hasZoom ? 1 : 0 } 22 |
23 |24 | { attributes.hasTip ? 1 : 0 } 25 |
26 |27 | { attributes.positionY } 28 |
29 |30 | { attributes.rotationY } 31 |
32 |{ attributes.scale }
33 |34 | { attributes.animations } 35 |
36 |Click and drag ^
115 | ) } 116 | > 117 | ); 118 | } 119 | -------------------------------------------------------------------------------- /blocks/three-object-block/editor.scss: -------------------------------------------------------------------------------- 1 | 2 | .wp-block-three-object-block { 3 | border: 1px dotted #f00; 4 | } 5 | .glb-preview-container { 6 | padding: 100px; 7 | text-align: center; 8 | align-items: center; 9 | align-content: center; 10 | background-color:#f2f2f2; 11 | } 12 | 13 | .glb-preview-container button{ 14 | padding: 15px; 15 | border-radius: 30px; 16 | } 17 | 18 | .three-object-viewer-button { 19 | background-color:rgb(199, 254, 0); 20 | color: black; 21 | border: solid 1.5px black; 22 | } 23 | 24 | .glb-preview-container button:hover{ 25 | border-radius: 30px; 26 | background-color:rgb(156, 199, 0); 27 | cursor: pointer; 28 | } 29 | .three-object-block-tip { 30 | overflow-wrap: break-word; 31 | background-color: black; 32 | color: white; 33 | padding: 10px; 34 | font-weight: 500; 35 | max-width: 160px; 36 | font-size: 12px; 37 | margin-top: 0px; 38 | margin: 0 auto; 39 | text-align: center; 40 | } 41 | 42 | .three-object-block-url-input { 43 | padding-bottom: 20px; 44 | } 45 | 46 | .three-object-block-url-input input{ 47 | height: 40px; 48 | } 49 | -------------------------------------------------------------------------------- /blocks/three-object-block/frontend.js: -------------------------------------------------------------------------------- 1 | const { Component, render } = wp.element; 2 | 3 | import ThreeObjectFront from "./components/ThreeObjectFront"; 4 | 5 | const threeApp = document.querySelectorAll(".three-object-three-app"); 6 | 7 | threeApp.forEach((threeApp) => { 8 | if (threeApp) { 9 | const threeUrl = threeApp.querySelector("p.three-object-block-url") 10 | ? threeApp.querySelector("p.three-object-block-url").innerText 11 | : ""; 12 | const deviceTarget = threeApp.querySelector( 13 | "p.three-object-block-device-target" 14 | ) 15 | ? threeApp.querySelector("p.three-object-block-device-target") 16 | .innerText 17 | : "2D"; 18 | const backgroundColor = threeApp.querySelector( 19 | "p.three-object-background-color" 20 | ) 21 | ? threeApp.querySelector("p.three-object-background-color") 22 | .innerText 23 | : "#ffffff"; 24 | const zoom = threeApp.querySelector("p.three-object-zoom") 25 | ? threeApp.querySelector("p.three-object-zoom").innerText 26 | : 90; 27 | const scale = threeApp.querySelector("p.three-object-scale") 28 | ? threeApp.querySelector("p.three-object-scale").innerText 29 | : 1; 30 | const hasZoom = threeApp.querySelector("p.three-object-has-zoom") 31 | ? threeApp.querySelector("p.three-object-has-zoom").innerText 32 | : false; 33 | const hasTip = threeApp.querySelector("p.three-object-has-tip") 34 | ? threeApp.querySelector("p.three-object-has-tip").innerText 35 | : true; 36 | const positionY = threeApp.querySelector("p.three-object-position-y") 37 | ? threeApp.querySelector("p.three-object-position-y").innerText 38 | : 0; 39 | const rotationY = threeApp.querySelector("p.three-object-rotation-y") 40 | ? threeApp.querySelector("p.three-object-rotation-y").innerText 41 | : 0; 42 | const animations = threeApp.querySelector("p.three-object-animations") 43 | ? threeApp.querySelector("p.three-object-animations").innerText 44 | : ""; 45 | 46 | render( 47 |10 | {attributes.threeObjectUrl} 11 |
12 |13 | {attributes.destinationUrl} 14 |
15 |16 | {attributes.scaleX} 17 |
18 |19 | {attributes.scaleY} 20 |
21 |22 | {attributes.scaleZ} 23 |
24 |25 | {attributes.positionX} 26 |
27 |28 | {attributes.positionY} 29 |
30 |31 | {attributes.positionZ} 32 |
33 |34 | {attributes.rotationX} 35 |
36 |37 | {attributes.rotationY} 38 |
39 |40 | {attributes.rotationZ} 41 |
42 |43 | {attributes.animations} 44 |
45 |46 | {attributes.label} 47 |
48 |49 | {attributes.labelOffsetX} 50 |
51 |52 | {attributes.labelOffsetY} 53 |
54 |55 | {attributes.labelOffsetZ} 56 |
57 |58 | {attributes.labelTextColor} 59 |
60 |10 | {attributes.textContent} 11 |
12 |13 | {attributes.positionX} 14 |
15 |16 | {attributes.positionY} 17 |
18 |19 | {attributes.positionZ} 20 |
21 |22 | {attributes.rotationX} 23 |
24 |25 | {attributes.rotationY} 26 |
27 |28 | {attributes.rotationZ} 29 |
30 |{attributes.scaleX}
31 |{attributes.scaleY}
32 |{attributes.scaleZ}
33 |{attributes.textColor}
34 |{attributes.scaleX}
11 |{attributes.scaleY}
12 |{attributes.scaleZ}
13 |14 | {attributes.positionX} 15 |
16 |17 | {attributes.positionY} 18 |
19 |20 | {attributes.positionZ} 21 |
22 |23 | {attributes.rotationX} 24 |
25 |26 | {attributes.rotationY} 27 |
28 |29 | {attributes.rotationZ} 30 |
31 |32 | {attributes.autoPlay ? 1 : 0} 33 |
34 |35 | {attributes.customModel ? 1 : 0} 36 |
37 |38 | {attributes.aspectHeight} 39 |
40 |41 | {attributes.aspectWidth} 42 |
43 |{props.attributes.scaleX}
93 |{props.attributes.scaleY}
94 |{props.attributes.scaleZ}
95 |96 | {props.attributes.positionX} 97 |
98 |99 | {props.attributes.positionY} 100 |
101 |102 | {props.attributes.positionZ} 103 |
104 |105 | {props.attributes.rotationX} 106 |
107 |108 | {props.attributes.rotationY} 109 |
110 |111 | {props.attributes.rotationZ} 112 |
113 |114 | {props.attributes.aspectHeight} 115 |
116 |117 | {props.attributes.aspectWidth} 118 |
119 |120 | {props.attributes.autoPlay ? 1 : 0} 121 |
122 |