Skip to content

Instantly share code, notes, and snippets.

@MastaMan
MastaMan / RemoveMissingBitmaps.mcr
Created November 14, 2023 09:41
A script that removes missing bitmaps, thus avoiding errors when opening a scene or packing a model for 3D Stocks
macroScript RemoveMissingBitmaps
buttontext: "RemoveMissingBitmaps"
category: "[3DGROUND]"
(
on execute do (
/*
Remove Missing Bitmaps
1.0.0
MastaMan
@MastaMan
MastaMan / loading.js
Created July 19, 2023 16:12
Loading - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
pc.script.createLoadingScreen(function (app) {
// Settings
var projectNameLine1 = 'Bing AI Gallery'; // Project name, line 1
var projectNameLine2 = ''; // Project name, line 2. You can use empty value '', for disable 2 line
var showControlsUsage = true; // Whether display keyboard shortcuts
var fontWidth = '3vw'; // Relative font size, depends on page width
var controlsSize = '8vh'; // Relative controls size, depends on page height
var progressBarHeight = '3px'; // Progress Bar height in pixels
///////////////////////////////////////////////////////////////////
@MastaMan
MastaMan / playSoundOnCollision.js
Created July 19, 2023 15:23
Play Sound On Collision - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
var PlaySoundOncollision = pc.createScript('playSoundOncollision');
PlaySoundOncollision.attributes.add('trigger', {
title: 'Trigger Entity',
description: 'Please select entity with collision.',
type: 'entity'
});
PlaySoundOncollision.attributes.add('soundName', {
title: 'Sound Name',
@MastaMan
MastaMan / lookAtPlayer.js
Created July 19, 2023 15:21
Look At Player - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
var LookAtplayer = pc.createScript('lookAtplayer');
// initialize code called once per entity
LookAtplayer.prototype.initialize = function() {
};
// update code called every frame
LookAtplayer.prototype.update = function(dt) {
this.entity.lookAt(this.app.player.camera.getPosition());
@MastaMan
MastaMan / infoPanel.js
Created July 19, 2023 15:17
Info Panel - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
var InfoPanel = pc.createScript('infoPanel');
InfoPanel.attributes.add('trigger', {
title: 'Trigger Entity',
description: 'Please select entity with collision.',
type: 'entity'
});
InfoPanel.attributes.add('timer', {
title: 'Load Timeout (s)',
@MastaMan
MastaMan / pulse.js
Created July 18, 2023 15:29
Pulse - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
var Pulse = pc.createScript('pulse');
Pulse.prototype.initialize = function() {
this.factor = 0;
this.size = 0.7;
this.growing = false;
this.s = this.size;
this.entity.setLocalScale(this.size, 0.01, this.size);
};
@MastaMan
MastaMan / pictureLoader.js
Created July 18, 2023 13:29
Picture Loader - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
var PictureLoader = pc.createScript('pictureLoader');
PictureLoader.attributes.add('timer', {
title: 'Load Timeout (s)',
description: 'Postpone loading in seconds.',
type: 'number',
default: 3
});
PictureLoader.attributes.add('pictureCaptionName', {
@MastaMan
MastaMan / pick-and-move.js
Created July 17, 2023 17:24
Pick And Move - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
var PickAndMove = pc.createScript('pickAndMove');
PickAndMove.attributes.add('playerSpeed', {
type: 'number',
default: 10,
title: 'Player Speed'
});
PickAndMove.attributes.add('hotspotEntity', {
title: 'Hotspot Entity',
@MastaMan
MastaMan / first-person-view.js
Created July 14, 2023 10:12
First Person View - Creating an interactive 3D portfolio gallery (WebGL/Playcanvas)
////////////////////////////////////////////////////////////////////////////////
// First Person Controls That Drive a Character Controller //
////////////////////////////////////////////////////////////////////////////////
var FirstPersonView = pc.createScript('firstPersonView');
FirstPersonView.attributes.add('camera', {
title: 'Camera',
description: 'The camera controlled by this first person view. It should be a child of the entity to which this script is assigned. If no camera is assigned, the script will create one for you.',
type: 'entity'
});
@MastaMan
MastaMan / loading.js
Last active April 10, 2023 14:11
Loading Screen script for Playcanvas Project SVOYA Apartment
pc.script.createLoadingScreen(function (app) {
// Settings
var projectNameLine1 = 'SVOYA'; // Project name, line 1
var projectNameLine2 = 'APARTMENT'; // Project name, line 2. You can use empty value '', for disable 2 line
var showControlsUsage = true; // Whether display keyboard shortcuts
var fontWidth = '10vw'; // Relative font size, depends on page width
var controlsSize = '8vh'; // Relative controls size, depends on page height
///////////////////////////////////////////////////////////////////